HTTP functions
get#
The 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(
Stringurl,MapparamsMap,MapheaderMap);
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 textpost#
The 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(
Stringurl,MapparamsMap,MapheaderMap,Stringbody);
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