RestServices.patch

Performs a REST HTTP PATCH call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PATCH call should be used for a partial update to a resource.

RestResponse contains the following data:

  • HTTP response code - returns a HTTP response code e.g 200 (OK)
  • HTTP response headers - returns list of response headers as key-->value pairs. e.g "WWW-Authenticate", "Bearer"
  • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

Example:

 var user = {};
 user.title = 'foo';
 
 var uri = "http://example.com/rest/users/1";
 //set any headers
 var headers = {"Content-Type":"application/json", "Accept":"application/json"};
 //set params
 var params = {"userId":fields.filter.value};
 //create authentication 
 var auth = HttpAuthentication.createBasicAuthentication("username", "password");
 var opts = new RestOptions();
 //setting the wait time to establish a connection to the target server to 5 seconds
 opts.setConnectionTimeout(5);
 //set the time to wait for no inactivity from the rest call to 10 seconds
 opts.setSocketTimeout(10);
 var response = services.rest.patch(uri, JSON.stringify(user), headers, params, auth, opts);
 if(response.isSuccess())
 {
      var result = JSON.parse(response.getBody());
      if(result)
      {
           //populate response using the JSON object
           displayResult(result);
      }
 }
 
Further documentation.

returns RestResponse

Parameters

java.lang.String  uri,  java.lang.String  body,  java.util.Map  headers,  java.util.Map  parameters,  Authentication authentication,  RestOptions options,