Http
Library of HTTP functions.
Functions
Delete
Creates an HTTP DELETE location.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Delete(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Get(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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.
Head
Creates an HTTP HEAD location.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Head(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Options(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Patch(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Post(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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.
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 withbodyBinary
. -
bodyBinary
: The data to send as the body of the request. Cannot be used withbodyString
. -
authCredentialName
: The name of the HTTP credential registered in the credentials storage. -
username
: The username to be used for basic authentication. Requirespassword
. -
password
: The password to be used for basic authentication. Requiresusername
. -
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.
Http.Put(
"https://www.somewhere.com/something",
headers = [{"Content-Type", "application/json"}],
args = [{"download", "true"}],
bodyString = Json.Print({name: "john", age: 35})
)
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
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.
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.
Http.UrlDecode(value: string)
Parameters
value
: The string to decode.
Returns
string
: The decoded string.
UrlEncode
Encodes a string as a URL.
Http.UrlEncode(value: string)
Parameters
value
: The string to encode.
Returns
string
: The encoded string.