Skip to content

Request

Creates a new RestRequest instance.

1
myRestClient.Request():RestRequest

Creates a new RestRequest instance with the specified resource.

1
myRestClient.Request(resource: string):RestRequest

Creates a new RestRequest instance with the specified resource and body.

1
myRestClient.Request(resource: string, body: ( string | object | Xml )):RestRequest

Parameters

string resource
    The resource to request.

( string | object | Xml ) body
    The request body.

Returns

A new RestRequest instance. A new RestRequest instance. A new RestRequest instance.

Remarks

The body argument is optional. If specified, the request method is automatically set to POST; otherwise, it defaults to GET.
XML-type bodies are automatically detected if the body is specified as an Xml object or a string that starts with "<" and ends with ">" characters.

JSON Request:

1
2
3
4
5
6
7
8
9
var client = $Rest.Create('http://targetserver/');

var request = client.Request("file/{id}", {
    field : 'value'
});

request.AddUrlParameter('id',123456);

var result = request.ExecuteJson();

XML Request:

1
2
3
4
5
6
7
var client = $Rest.Create('http://targetserver/');

var request = client.Request('file/{id}','<root><field>value</field></root>');

request.AddUrlParameter('id',123456);

var result = request.ExecuteXml();

See Also