Call Ninox API with the http() function via the formula editor
To call other services on the internet, use the formula editor in the Ninox app and Ninox API. Query information or send updates with the http()
function from other REST services. The http()
function can be used in triggers with POST
, however not with GET
.
When called from a button, the http()
function executes in the client/web browser context. To prevent this, place do as server {http(…) end}
between the function and the button.
method: GET
, POST
, PUT
, DELETE
url: a valid HTTP/HTTP URL
headers: a JSON object specifying the HTTP header
body: a string or an arbitrary JSON object
A JSON object containing either an error or a result property
Content in curly brackets{ }
signifies a placeholder. Both the curly brackets and the content within must be replaced for the request to work.
GET
request without an authorization headerGET
request with an authorization headerPOST
request with an authorization headerYou may want to run HTTP queries through the Ninox Cloud server instead of through the client. This is particularly important when calling non-SSL APIs, as the Ninox native applications for Mac, iPhone, and iPad are unable to query insecure endpoints.
To enforce execution of code on the Ninox Cloud server, embed the http()
function in ado as server
block.
When path parameters contain spaces or special characters, they require specific encoding. To handle that encoding, Ninox script includes a number of functions:
JSON syntax is derived from JavaScript Object Notation syntax:
Data is in name/value pairs
A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value
Data is separated by commas
Curly braces hold objects
Square brackets hold arrays
Numbers as whole numbers with dot .
as decimal separator
When a property name contains spaces or special characters or starts with a number, it needs to be quoted in single quotes ' '
. To include a single quote within a property name, write two single quotes.
Optionally, escape reserved key words like order
,from
, andto
in single quotes' '
when using these key words as property names.
String values need to be enclosed in double quotes " "
. To include a double quote within a string value, write two double quotes.
Property values and members of arrays can also be constructed using arbitrary Ninox expressions.
Most services will return JSON objects. You can handle and evaluate JSON objects with Ninox script.
You can access object values or properties by using dot .
notation.
Ninox script is a statically-typed functional language, which means a JSON object has no schema specification. As a result, specifying or converting the type of a property is occasionally needed. To convert values, use the functions text
, number
, date
, datetime
, time
, appointment
, url
, and phone
.
Use the functions first
, last
, and item
to extract an item from an array.
To loop over the items of an array, use the for...in
statement.
HTTP
Ninox script
urlEncode("Test Parameter")
"Test%20Parameter"
urlDecode("Test%20Parameter")
"Test Parameter"
url("http://mytestapi.com", { page: 1, perPage: 20, order: "First Name" })
"http://mytestapi.com?page=1&perPage=20&order=First%20Name"
JSON syntax
Description
{ }
an empty object
[ ]
an empty array
12.56
a number
"Lisa"
a string
{ name: "Lisa" }
an object containing a string
{ name: "Lisa", age: 28 }
an object containing a string and a number
{ name: "Lisa", age: 28, address: { street: "A Street" } }
an object containing two strings and a number
{ name: "Lisa", children: [ { name: "Charlie" }, { name: "Sarah" } ] }
an object containing an array that contains two strings