How to call web services from Sapho

Last update:

Audience: Developers building Sapho micro apps

Many SaaS, and even some on-premises, applications typically use REST APIs with responses in JSON. You can use our JSON connector to call these APIs right from within Sapho and work with their response data.

JSON connector basics

To create a JSON connector, please follow these steps:

  1. Go to Micro Apps in Sapho Builder and add a new JSON micro app.
  2. Select Connect to JSON in the dialog window and click Next.
  3. Enter your Base URL settings (this is the root of the URL used for the API call).
  4. If your API calls are secured using authentication, please fill in the Username and Password fields.
  5. Using the Base URL, you can set up multiple Tables to load the JSON responses from different API calls. Click the blue + icon to start defining a table.
  6. In the Add Table dialog, please enter the URI. This is the rest of API calls’ URL, excluding any GET parameters. In the screenshot below, the URI’s value is issues.
  7. Enter Table Name. This will be used to reference the table within Sapho Builder.
  8. It is also possible to add additional GET or POST request parameters in combination with date-based variables. Click SET PARAMS in Request Params to configure request parameters and request type.

    You also have the option to select GET or POST under Request Type. For the example used above, we set up a GET parameter with the name state, a value of closed, and a Request Type of GET.
  9. Click Load Columns to load all the available attributes from the JSON response. Sapho will automatically detect and set the data type of each attribute, but you can update them manually as well. You can also set which attribute is the primary key and any attributes that should be ignored during the data import.
  10. Click Save to close the Add Table window and then click Next.
  11. You can set up a Synchronization Schedule, i.e. how often the configured API call will be executed and data from its response saved to the Sapho cache for further use in micro apps and/or events. To do this, configure how often you would like your API call to execute.
  12. Click Done to finish your JSON connector setup.

JSON connector limitations

Although the JSON connector is a very powerful tool, it is currently limited in order to support very straightforward integrations that sync data in order to trigger events and let users perform lookups:

  • Flat JSONs only - Our JSON connector currently does not t support nested attribute sets so you can only access attributes on the first level of a JSON document.
  • Basic Auth only - Sapho cannot currently support anything other than basic API authentication.