$Rest¶
Allows interaction with REST services using JSON or XML content types. REST service operations involve the following objects: RestClient, RestRequest, and RestResponse.
1 | |
Remarks¶
A typical call has three steps:
- Create a client for the base URL of the service with
$Rest.Create. Pass a service name to authenticate with OAuth2 credentials configured in the domain. - Create a request for a resource with RestClient.Request and add parameters, headers and a body.
- Execute the request. RestRequest.ExecuteJson and RestRequest.ExecuteXml return the parsed body; RestRequest.Get, RestRequest.Post, RestRequest.Put, RestRequest.Patch and RestRequest.Delete return a RestResponse.
All methods except RestRequest.Execute and RestRequest.ExecuteAsync verify the response status code and throw an error for unexpected status codes. Use RestRequest.Expect to accept other status codes.
Methods ending with Async return a Promise; use .then(function (result) { ... }) to read the result.
Examples¶
Read JSON from a service¶
1 2 3 4 5 6 7 | |
Call an authenticated service¶
1 2 3 4 5 6 | |
Handle the response yourself¶
1 2 3 4 5 6 7 8 9 10 11 12 | |
Capabilities¶
Client Creation¶
$Rest.Create: Creates a new RestClient instance.