HTTP functions
#
getThe get function corresponds to a HTTP GET request. It is normally supported by services to perform a read operation like fetching data.
Syntax:
new NameSpace("http").get(
String
url,Map
paramsMap,Map
headerMap);
Parameters:
Param | Data type | Description |
---|---|---|
url | String | The URL which will return the response. |
paramsMap | Map | Variable holding param values as key-value pairs. |
headerMap | Map | Variable holding header values as key-value pairs. |
Returns: String
Example:
url = "http://<some url to be fetched>";paramsMap = {};paramsMap.fetchLimit = 100;
headerMap = {};headerMap.Authorization = "Bearer token";
response = new NameSpace("http").get(url, paramsMap, headerMap);log response; // response content as text
#
postThe post url task corresponds to a HTTP POST request. It is normally supported by services to perform write operation like adding or updating data.
Syntax:
new NameSpace("http").post(
String
url,Map
paramsMap,Map
headerMap,String
body);
Parameters:
Param | Data type | Description |
---|---|---|
url | String | The URL which will return the response. |
paramsMap | Map | Variable holding param values as key-value pairs. |
headerMap | Map | Variable holding header values as key-value pairs. |
body | String | Data to be posted. |
Returns: String
Example:
url = "http://<some url to be posted>";paramsMap = {};paramsMap.fetchLimit = 100;
headerMap = {};headerMap.Authorization = "Bearer token";
body = "Some dummy content to be posted";
response = new NameSpace("http").post(url, paramsMap, headerMap, body);log response; // response content as text