Skip to main content

Http

Library of HTTP functions.

Functions

Delete

Creates an HTTP DELETE location.

Syntax:
Http.Delete(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Delete(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Get

Creates an HTTP GET location.

Syntax:
Http.Get(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Get(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Creates an HTTP HEAD location.

Syntax:
Http.Head(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Head(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Options

Creates an HTTP OPTIONS location.

Syntax:
Http.Options(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Options(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Patch

Creates an HTTP PATCH location.

Syntax:
Http.Patch(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Patch(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Post

Creates an HTTP POST location.

Syntax:
Http.Post(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Post(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Put

Creates an HTTP PUT location.

Syntax:
Http.Put(url: string, bodyString: optional string, bodyBinary: optional binary, authCredentialName: optional string, username: optional string, password: optional string, args: optional list, headers: optional list, expectedStatus: optional list)
Parameters
  • url: The HTTP URL.

  • bodyString: The string data to send as the body of the request. Cannot be used with bodyBinary.

  • bodyBinary: The data to send as the body of the request. Cannot be used with bodyString.

  • authCredentialName: The name of the HTTP credential registered in the credentials storage.

  • username: The username to be used for basic authentication. Requires password.

  • password: The password to be used for basic authentication. Requires username.

  • args: The query parameters arguments for the HTTP request, e.g. [{"name", "john"}, {"age", "22"}]. They are URL-encoded automatically.

  • headers: The HTTP headers to include in the request, e.g. [{"Authorization", "Bearer 1234"}, {"Accept", "application/json"}].

  • expectedStatus: The list of expected statuses.

Returns
  • location: A location to read from.
Example:
Http.Put(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
note

Any key/value pair with a null key or value in the headers or in the args parameters will be omitted and won't be included in the request.

Read

Makes an HTTP call

Syntax:
Http.Read(location: location, expectedStatus: list)
Parameters
  • location: The HTTP location.

  • expectedStatus: The list of expected HTTP status codes. If the response status code received is not on the list, the call fails with an error.

Returns
  • record(status: int, data: binary, headers: list(record(_1: string, _2: string)))): The HTTP response.
Example:
let
request = Http.Read(
Http.Post(
"http://localhost:1234/return-body",
bodyString = "Hello World",
username = "user",
password = "passwd"
)
)
in
String.Decode(request.data, "utf-8")"

UrlDecode

Decodes a URL-encoded string.

Syntax:
Http.UrlDecode(value: string)
Parameters
  • value: The string to decode.
Returns
  • string: The decoded string.

UrlEncode

Encodes a string as a URL.

Syntax:
Http.UrlEncode(value: string)
Parameters
  • value: The string to encode.
Returns
  • string: The encoded string.