Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

RestRequest RestRequest myRestRequest.AddParameter(name: string, value: object)

RestRequest RestRequest myRestRequest.AddParameter(name: string, value: object, type: ( "Cookie" | "GetOrPost" | "UrlSegment" | "HttpHeader" | "RequestBody" | "QueryString" | "QueryStringWithoutEncode" ))

...

Type of parameter. Optional.

Remarks

Type parameter is optional. If not specified default value is "GetOrPost".

Type parameter can be one of following;

GetOrPost

Cookie

HttpHeader

RequestBody

QueryString

Example

Code Block
languagets
var client = $Rest.Create('http://targetserver');
var request = client.Request();

request.AddParameter('x', 1);
request.AddParameter('y', {
  z : 3
});

// request body as
// {
//    "x" : 1,
//    "y" : {
//        "z" : 3
//    }
// }

var response = request.ExecuteJson();

Remarks

Type parameter Name and value arguments are required.

Type parameter is optional. If not specified default value is "GetOrPost".

...

HttpHeader

RequestBody

QueryString

Example

...

Code Block
languagets
var client = $Rest.Create('http://targetserver');
var request = client.Request();

request.AddParameter('x', 1);
request.AddParameter('y', {
  z : 3
});

// request body as
// {
//    "x" : 1,
//    "y" : {
//        "z" : 3
//    }
// }

var response = request.ExecuteJson();

...

Code Block
languagets
var client = $Rest.Create('http://targetserver');
var request = client.Request();

request.AddParameter('x', 1);
request.AddParameter('y', {
  z : 3
});

// request body as
// {
//    "x" : 1,
//    "y" : {
//        "z" : 3
//    }
// }

var response = request.ExecuteJson();