Skip to content

ExecuteJson

Executes the request and returns the response body as a JavaScript object.

1
myRestRequest.ExecuteJson():( object | null )

Returns

The response body parsed as JSON.

Remarks

Unlike RestRequest.Execute, this method verifies the response status: by default, OK (200) and NoContent (204) are accepted. Otherwise, an exception is thrown.

Examples

Copy values from a JSON response

1
2
3
4
5
6
7
8
var customer = $Rest.Create('https://api.example.com/')
    .Request('customers/{id}')
    .AddUrlParameter('id', $Xml.Evaluate('Customer/Id'))
    .ExecuteJson();

// { "name" : "Jane Doe", "email" : "[email protected]" }
$Xml.SetValue('Customer/Name', customer['name']);
$Xml.SetValue('Customer/Email', customer['email']);

See Also