Skip to content

RestClient.Request

Overview

RestRequest RestClient.Request ( [ resource ] , [ body ] )
Creates a RestRequest instance.

Arguments

String resource Resource part of URL.

Object | XmlProxy | String body Request body.

Remarks

  • Body argument is optional. If specified request method automatically set to POST, otherwise is set to GET
  • Xml type of body is automatically detected if specified as XmlNode or string with starts with "<" and ends with ">" characters.

Examples

JSON Request

var client = $Rest.Create('http://targetserver/');

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

request.AddUrlParameter('id',123456);

var result = request.ExecuteJson();

Xml Request

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