Skip to content

RestRequest.AddParameter

Overview

RestRequest RestRequest.AddParameter ( name, value, [ type ] )
Adds a new parameter to request

Arguments

String name

Name of parameter

Object value

Value of parameter

String type

Type of parameter. Optional.

Remarks

  • Name and value arguments are required.
  • Type parameter is optional. If not specified default value is "GetOrPost".
  • Type parameter can be one of following;
    • GetOrPost
    • Cookie
    • HttpHeader
    • RequestBody
    • QueryString

Examples

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();

See Also