rest

How do I make my Web Application stateless yet still do somthing useful?

I've seen this advice... ideally the web should follow the REST principle and be completely stateless. Therefore a single URL should identify a single resource, without having to keep the navigation history of each user. ...and I read the Wikipedia page http://en.wikipedia.org/wiki/REST and it really sounds good, but I don't get ho...

RESTful copy/move operations?

I am trying to design a RESTful filesystem-like service, and copy/move operations are causing me some trouble. First of all, uploading a new file is done using a PUT to the file's ultimate URL: PUT /folders/42/contents/<name> The question is, what if the new file already resides on the system under a different URL? Copy/move Idea 1:...

How to send a JSONObject to a REST service?

Retrieving data from the REST Server works well, but if I want to post an object it doesn't work: public static void postJSONObject(int store_type, FavoriteItem favorite, String token, String objectName) { String url = ""; switch(store_type) { case STORE_PROJECT: url = URL_STORE_PROJECT_PART1...

RESTful API design question - how should one allow users to create new resource instances?

I'm working in a research group where we intend to publish implementations of some of the algorithms we develop on the web via a RESTful API. Most of these algorithms work on small to medium size datasets, and in many cases, a user of our services might want to run multiple queries (with different parameters) on the same dataset, so for ...

Consume restful webservice through web proxy

Hello, I'm trying to consume a restful webservice in java using the Apache Wink framework through my school web proxy requiring authentification ClientConfig clientConfig = new ClientConfig(); clientConfig.proxyHost("proxy.school.com"); clientConfig.proxyPort(3128); //nothing to set username and password :( RestClient client = new Res...

How can I return json from my WCF rest service (.NET 4), using Json.Net, without it being a string, wrapped in quotes?

UPDATE 10/19/2010 I know I asked this question a while ago, but the workarounds shown in these answers are hardly satisfactory, and this is still a common problem for many. WCF just isn't flexible. I started my own open source C# library for creating REST services without WCF. Check restcake.net or rest.codeplex.com for info on said l...

Restful route helpers using '.' instead of '/' in path

My path helpers (like data_path, users_path) are now translating itself to use '.' instead of '/'. For example, data_path(@data) translates to: data.%23<datareport:0x7fcaba0c2970> instead of '/data/id'. My routes look like: map.resources :data ...

Inject a EJB into JAX-RS (RESTfull service)

I'm trying to inject Stateless EJB into my JAX-RS webservice via Annotations. Unfortunately the EJB is just null and I get a NullPointerException when I try to use it. @Path("book") public class BookResource { @EJB private BookEJB bookEJB; public BookResource() { } @GET @Produces("application/xml") @Path(...

How to do REST with PUT and DELETE

It says about the type option of the jQuery.ajax() method that The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers. So... Does that mean that PUT and DELETE won't work if the browser does not su...

how to send JSON data with server error response code 500

I wanted to know if theres a way to send a JSON data along with HTTP response code 500. Basically I want my rest client to know that there is some error on the backend and along with it send a JSON error data structure like this. {"error" : [ {"code": "1001", "desc": "Some error description"}, {"code": "1002", "desc"...

Cross-domain REST proxy with Javascript, HTML5

I'm writing a service (say, service.com) that provides a REST API to external apps running inside of IFrames. (These apps are hosted from domains outside the service.com). I'm planning a javascript client library for the apps to make pure-javascript requests to the service.com REST API -- basically using postMessage and some ad-hoc en...

Looking for a way to get HTTP Digest Authentication headers from incoming http requests

I've been working on a REST implementation with my existing Cake install, and it's looking great except that I want to use HTTP Digest Authentication for all requests (Basic Auth won't cut it). So great, I'll generate a header in the client app (which is not cake) and send it to my cake install. Only problem is, I can't find a method f...

What are the Rails best practices for javascript templates in restful/resourceful controllers?

First, 2 common (basic) approaches: # returning from some FoosController method respond_to do |format| # 1. render the javascript directly format.js { render :json => @foo.to_json } # 2. render the default template, say update.js.erb format.js { render } end # in update.js.erb $('#foo').html("<%= escape_javascript(render(@foo)...

How to remove default header from WCF REST Outgoing Response?

The following C# WCF based REST service gives me some undesired headers that I'm not sure if I can remove them trough the API. The interface: [ServiceContract] public interface IControlSystem { [OperationContract] [WebGet] System.IO.Stream About(); } The implementation: public class ControlSystem : IControlSystem { p...

Secure/Best Practices for Account Creation for app that uses REST services?

I apologize if this is a somewhat stupid question, but I am very new to the REST programming realm. I have an application that is both web, mobile and machine accessible, and I will be leveraging REST-like web services for the mobile and machine part. I was going to use the S3 authentication model for the REST requests, however that re...

Generic Open Source REST Client?

I want a simple client that takes a few parameters (Method, URL, Parameters), makes an HTTP request, and shows me the results that were returned. A browser obviously can easily send GET and POST requests, but I have no good ideas on DELETE and UPDATE. Did I miss something in browser 101, or is there a common freeware tool to do this?...

URL encoded POST bad practice?

I am (just for fun) trying to implement a High Score web-service. I would like it be compatible with REST principles. I want to be able to add a new highscore using url parameters like this http://mydomain.com/hs/add&amp;name=John&amp;score=987. According to REST this must be done using a POST request. Which leads to empty POST request w...

WCF Restful services getting error 400 (bad request) when post xml data

I am trying to self host a WCF services and calling the services via javascript. It works when I pass the request data via Json but not xml (400 bad request). Please help. Contract: public interface iSelfHostServices { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = INFOMATO.RestTemplate.hello_post2,RequestForma...

MVC2 or WCF for an XML/JSON REST API?

I spent a long time learning how to customise WCF from the point of view of adding authentication etc over a RESTful service; I built some custom service hosts, then added the ability to use an IOC container to actually create the service instance etc etc. We have iPhone/iPad apps plus some other gadgety-type things (technical term!) th...

How to create an "edit" url for a restful resouce?

In my partial template, there is a varible named "resource", it may be a question or an answer. I want to build a link to edit it, but when I use it, I don't know what it is, so I can't write: <%=link_to 'edit', edit_question_url(resource)%> or <%=link_to 'edit', edit_answer_url(resource)%> I wonder if there is such a method, say...