Search
⌃K
Links

http

To send an HTTP request
With this function, you can make an API call to access data outside your current database. You can integrate some external services or exchange data between 2 databases.
This function can take up to 4 parameters:
  • Method A string defining the HTTP method for the API call. This is usually "GET", "POST", "PUT", or"DELETE"
  • URL A string holding the URL to the external service
  • Header An optional JSON object containing meta information of the API call like an API key or the content type.
  • Body An optional JSON object usually containing the data that will be shared with other external services.
Using API might need some extra knowledge. Learn more about API >​
To access a Ninox database you need an API key. How to get an API key​
We recommend executing this function together with do as server. More about Optimize performance of scripts ​

Syntax

http(string, string)
http(string, string, JSON)
http(string, string, JSON, JSON)

With files

http(string, string, JSON, [file])
http(string, string, JSON, JSON, [file])

Return

JSON

Examples

http(method, url) To call REST services without a header or body.
​
http(method, url, header) To call REST services—the method and URL are strings; the (optional) header is a JSON object.
​
http(method, url, header, body) To call REST services—the method and URL are strings (header and body are optional objects).
1
let url := "https://api.ninoxdb.de/v1/teams/" + teamId() + "/databases/" + databaseId() + "/tables/";
2
let myAPIKey := "Bearer abcd1234-0000-xxxx-zzzz-1a1aa1aaa1a111";
3
let response := http("GET", url, {
4
Authorization: myAPIKey
5
}, null);
6
response
Result: You will receive a JSON object either containing all tables of the database if the API call is successful, or a JSON object containing an error message if not.
​
1
do as server
2
let url := "https://api.ninoxdb.de/v1/teams/" + teamId() + "/databases/" + databaseId() + "/query";
3
let APIKey := "Bearer abcd1234-0000-xxxx-zzzz-1a1aa1aaa1a111";
4
let response := http("POST", url, {
5
Authorization: APIKey,
6
'content-type': "application/json"
7
}, {
8
query: "select Kunden where Status = 4"
9
});
10
response
11
end
Result: You will receive a JSON object either containing all records of the Customers table, where the Status = 4, if the API call is successful or a JSON object containing an error message if not.

With files

http(method, url, header, files) To call REST services and include a list of files - the method and URL are strings; the (optional) header is a JSON object.
​
http(method, url, header, body files) To call REST services and include a list of files - the method and URL are strings (header and body are optional objects).

See also

More about API calls in Ninox script​
Last modified 6mo ago