Call an API or run code
Reach any service with a REST or GraphQL API, or compute something no built-in step covers. Use them when nothing else fits.
Two built-in steps can do almost anything: Call an API reaches any web API, and Run code runs a short script. Every other step shows its app and labeled fields, which anyone on your team can read and change. These two show a URL and headers, or a block of code. Reach for them when no app action or built-in step does the job.
Call an API
Call an API calls a REST or GraphQL endpoint that Lodol has no app for, and hands the response to later steps.
| Field | What it's for |
|---|---|
| URL | The full address, starting with https://. It can include workspace values, such as @values.BASE_URL followed by a path. |
| Method | GET unless you choose another |
| Headers | Such as an Authorization header, using a secret for the token |
| Query parameters | Added to the end of the URL |
| Body | What to send, as JSON or a value from an earlier step. GraphQL queries go here too. |
| Body format | json (the default), form, text, multipart (to upload files) or none |
| Response format | auto (the default) follows the response's content type, so JSON becomes an object and a download becomes a file |
| Error responses | Fail the step (the default), or treat error statuses as results so later steps can check the status |
The step returns the response's status, ok (true for a success status), headers, body and url.
For apps Lodol has, use their actions
A Call an API step only has the secrets you give it, unless you choose a connection in its Connection field, which some apps allow, such as Google's, HubSpot and Notion: then it's signed in as that account, and can only call that app's own servers. Use that for an endpoint an app's actions don't cover; for anything else in the directory, use its actions.
Run code
Run code runs a short script, in Python (the default) or JavaScript, for the rare reshaping or calculation no built-in step covers.
- Inputs maps names to values from earlier steps; the script reads them by those names.
- The script's result is whatever it assigns to a variable named
output. - Output type checks the result before later steps use it:
auto(the default),text,number,boolean,listorobject.
# Inputs: iban (text). Output type: boolean.
iban = iban.replace(" ", "").upper()
rearranged = iban[4:] + iban[:4]
digits = "".join(str(int(char, 36)) for char in rearranged)
output = int(digits) % 97 == 1The script runs in a secure sandbox with limits on time and memory. It has no internet or file access: use Call an API or an app's action to reach a service, and Read a file to get what's inside a file.
Before writing code, check the built-in steps: most text, list, number and date work, such as grouping records by a field, totalling a column or formatting a date, already has a step.