Skip to main content

Description

Makes a REST API call and returns the response received from the server. Requests are made either anonymous or with basic authentication. To authenticate with a saved Integrate.io ETL connection instead, including Universal OAuth, use CCurl.

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.
    Note:Only url and method are required; however, if you need to pass a later argument, make sure you include empty single quotes for the arguments you aren’t passing. See the third example below.

Examples

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

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.

Redirect handling

When Curl() follows an HTTP redirect, it compares each hop with the origin (scheme, host and port) of the URL passed in. Redirects within the same origin send every header as usual. A same-host upgrade from http (port 80) to https (port 443) also counts as the same origin. When a redirect leaves that origin, Curl() drops Authorization, Proxy-Authorization, Cookie, and any header in the headers argument whose name contains auth, token, api-key (or apikey, api_key), secret, passw, session or credential, for example X-Api-Key. Other headers passed in the headers argument are still sent to the redirect target. This lets a call succeed when the endpoint returns a 302 to a pre-signed URL on another host, such as S3. Without it, the second host would reject the request for carrying two authentication mechanisms. A same-host redirect from https to http that carries credentials fails with Refusing to follow a redirect from https to http. A call follows at most 20 redirects, then fails with Maximum redirects (20) exceeded. When the response has a non-2xx status, credentials in the returned body are replaced with <REDACTED>. Bodies of 2xx responses are never changed.
Last modified on December 1, 2026