FIN HTTP Axon APIs

Please note, there is also an existing API called ioReadJson() that enables a developer to GET data from an endpoint. This function doesn’t support additional HTTP headers or different HTTP verbs (only GET).

These Axon functions are available from 5.0.6 onward.

Here are some examples of using the new FIN HTTPS Axon APIS…

GET some JSON data and write it to Folio

  • GET some data from a REST API

    • The response can handle both Zinc and JSON encodings.

    • If JSON, it attempts to decode it as a Grid.

    • If it can’t be parsed as a JSON Grid then it’ll convert the vanilla JSON into a Grid.

  • Add a marker tag so the record can be easily reference again

  • Remote the id property so the data can be committed to Folio without any errors

  • If the record already exists then update the record with the new data

() => do res: finHttpGet(`https://jsonplaceholder.typicode.com/todos/1`) .first .set("restApiResult", marker()) .remove("id") rec: read(restApiResult, false) if (rec == null) diff(null, res, {add}).commit else diff(rec, res).commit end

To regularly pull data from the Cloud, try using the above code in a job.

GET some JSON data with an authorization bearer token

Write the secure token to the project database. Never hard code security tokens in Axon script…

passwordSet("FIN_AUTH_TOKEN_MYTOKEN", "mySuperSecretPassword")
  • GET some data from a REST API

  • Reference the authorization token and add it to the outgoing HTTP request with an Authorization header with a bearer token value

finHttpGet(`http://localhost:8088/mySecureApi`, { authorization: "Bearer \$FIN_AUTH_TOKEN_MYTOKEN" })

POST a JSON encoded Grid to an HTTPS end point

PUT a Zinc encoded Grid to an HTTPS end point