Skip to content

RestRequest

Represents a single request to a REST service.

Remarks

Create a request with RestClient.Request, then add URL, query and form parameters, headers, files or a body. The Add... methods return the request, so calls can be chained.

Execute the request with a method helper such as RestRequest.Get or RestRequest.Post. These helpers check the response status and throw an error for an unexpected status; use RestRequest.Expect to accept other statuses. RestRequest.Execute sends the request with its RestRequest.Method and does not check the status. Methods that end with Async return a Promise.

Examples

Send a form with a file

1
2
3
4
5
6
var response = $Rest.Create('https://archive.example.com/api/')
    .Request('documents')
    .AddParameter('title', $Xml.Evaluate('Title'))
    .AddFile('file', $Xml.Evaluate('Attachment'))
    .Expect('Created')
    .Post();

Capabilities

Request Definition

  • RestRequest.Method: Gets or sets the HTTP method of the request, such as Get, Post, Put, Patch or Delete.

Request Parameters and Body

Execution

Request Expectations