REST request class members
44.2.2. The REST.Request class The REST.Request class is used to build custom requests. It has the following members: Table 44.5. The REST.Request class Member Description execute(callback) Executes the request with all the information set in the current object. The value is never returned but passed to the optional argument callback. setAccepts(acceptHeader) Sets the Accept request header. Defaults to */*. setCredentials(username, password) Sets the request credentials. setEntity(entity) Sets the request entity. setContentType(contentTypeHeader) Sets the Content-Type request header. setURI(uri) Sets the request URI. This should be an absolute URI. setMethod(method) Sets the request method. Defaults to GET. setAsync(async) Controls whether the request should be asynchronous. Defaults to true. addCookie(name, value) Sets the given cookie in the current document when executing the request. Beware that this will be persistent in your browser. addQueryParameter(name, value) Adds a query parameter to the URI query part. addMatrixParameter(name, value) Adds a matrix parameter (path parameter) to the last path segment of the request URI. addHeader(name, value) Adds a request header. Example 44.7. Using the REST.Request class The REST.Request class can be used to build custom requests: var r = new REST.Request(); r.setURI("http://api.service.com/orders/23/json"); r.setMethod("PUT"); r.setContentType("application/json"); r.setEntity({id: "23"}); r.addMatrixParameter("JSESSIONID", "12309812378123"); r.execute(function(status, request, entity){ log("Response is "+status); });