Skip to main content

REST

All REST functions automatically retry failed requests based on the rules described here.

When all retries are exhausted, the error is logged and null is returned. The functions do not raise exceptions.

rest_get

Performs a REST GET from the account at the specified path.

Returns the parsed JSON response, or null on error.

let result = rest_get("path", [account]);

Example:

let user = rest_get("users/5", "myApi");
log("user:", user); // => { id: 5, name: 'Alice', email: 'alice@example.com' }

rest_delete

Performs a REST DELETE from the account at the specified path.

Returns the parsed JSON response, or null on error.

let result = rest_delete("path", [account]);

Example:

let result = rest_delete("users/5", "myApi");
log("result:", result);

rest_post

Performs a REST POST to the account at the specified path.

Returns the parsed JSON response, or null on error.

rest_post("path", data, [account]);

Example:

let result = rest_post(
"users",
{
name: "Alice",
email: "alice@example.com",
},
"myApi",
);
log("created:", result); // => { id: 6, name: 'Alice', email: 'alice@example.com' }

rest_put

Performs a REST PUT to the account at the specified path.

Returns the parsed JSON response, or null on error.

rest_put("path", data, [account]);

Example:

let result = rest_put(
"users/5",
{
name: "Alice",
email: "alice@newdomain.com",
},
"myApi",
);
log("updated:", result);

rest_patch

Performs a REST PATCH to the account at the specified path.

Returns the parsed JSON response, or null on error.

rest_patch("path", data, [account]);

Example:

let result = rest_patch(
"users/5",
{
email: "alice@newdomain.com",
},
"myApi",
);
log("patched:", result);