Skip to main content

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(String url, Map paramsMap, Map headerMap);

Parameters:

ParamData typeDescription
urlStringThe URL which will return the response.
paramsMapMapVariable holding param values as key-value pairs.
headerMapMapVariable 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

post#

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(String url, Map paramsMap, Map headerMap, String body);

Parameters:

ParamData typeDescription
urlStringThe URL which will return the response.
paramsMapMapVariable holding param values as key-value pairs.
headerMapMapVariable holding header values as key-value pairs.
bodyStringData 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
On This Topic