Curl

Description

Makes a REST API call and returns the response received from the server. Requests are made either anonymous or with basic authentication.

Syntax

Curl(url, method[, headers[, request_body[, username[, password]]]])

Arguments

url - HTTP or HTTPS url for the request.

method - HTTP method, such as GET, POST, PUT, DELETE, PATCH.

headers (optional) - A json string that identifies the header key and value in the following manner: '{"header1" : "value1" , "header2" : "value2"}'

request_body (optional) - The string body of the request (most relevant in the case of POST)

username (optional) - The user name for basic authentication. Can be empty string if the site does not require authentication.

password (optional) - The password for basic authentication. Can be empty string if the site does not require authentication.

Examples

Curl('http://api.myapp.com/users/','POST','{"Accept":"text/json"}','{"name":"John","age":34}','myuser','mypass')

Curl('http://api.myapp.com/users/','GET')

Return value datatype

The returned value is a map object that contains the following keys:

  • status - response code (integer)
  • body - the body of the response (string)
  • headers - map object of response headers

Impact of null value

The url and method arguments are required. The rest are optional and default to null.