Nowadays, more and more data in external systems and cloud applications becomes available via web (REST) APIs. With EasyMorph you can send highly configurable web (HTTP) requests in order to retrieve data, submit new and change existing data, and trigger processes via web APIs. For this, EasyMorph provides:
- Connector "Web Location"
- Action "Construct JSON" for transforming tabular data into JSON
- Actions "Web Request" and "Iterate Web Request" for sending HTTP requests and obtaining responses
- Action "Parse JSON" for transforming JSON into tabular data
If you're new to web APIs, we recommend reading this article first: Making your data better with web APIs.
Connector "Web Location"
The "Web location" connector specifies common properties of a web API, such as base URL or proxy settings. It also allows specifying URL parameters and request headers that must be included with every web request sent using this connector. Such URL parameters and/or headers can be used for specifying API keys and secret tokens required for authentication.
Under the hood, the connector also contains a cookie container which is passed from request to request. Cookies in the container are set and retrieved automatically by each web request.
Action "Import from Web API"
The "Import from Web API" action is a simple way to pull data out of a web API. It can send only HTTP GET requests, and automatically recognizes and parses responses with a JSON or XML body.
Note that the final request URL is concatenated from the base URL specified in the "Web Location" connector, and the URL path specified in the action. For instance, for the action shown in the screenshot below the final request URL is https://community.easymorph.com/posts.json assuming that it uses the "Web Location" connector depicted above.
Request headers can be configured in the tab "Headers". Headers "Content-Length" and "Accept" are inserted automatically, therefore they don't have to be specified explicitly.
Action "Web request"
The "Web request" action is a more advanced action than "Import from Web API". Besides GET, it can send HTTP requests of all the other types — POST, HEAD, PUT, etc., and configure a request body.
For HTTP methods that require a request body (e.g. POST), there are a few ways to construct the body such as simple JSON, or web-form emulation. Header "Content-Length" is inserted automatically. Note that the action has a preview pane for previewing the raw HTTP request sent to the remote endpoint, and the response.
As per action settings, the HTTP response can be ignored, or captured, or its contents (body) can be saved into a file. See this web-help article for detailed documentation of configuring the "Web request" action: Action "Web Request".
Unlike "Import from Web API", the "Web request" action doesn't parse the response automatically. The [Response-Body] column contains the request response and can be parsed using the "Parse JSON", or "Parse XML" actions (or any other action depending on response contents).
Web APIs typically operate with data in hierarchical formats such as JSON or XML, while EasyMorph is optimized for tabular datasets. To facilitate transition from JSON/XML to tables and back, EasyMorph provides the following actions:
- Construct JSON (see example)
- Parse JSON
- Parse XML (available from v4.2)
Note that all these actions can work with multiple JSONs at once. For instance, "Construct JSON" can be configured to produce a column with a uniform JSON in each row. Similarly, "Parse JSON" can parse JSONs contained in each cell of a column, and automatically append the result into one table.
Besides that, there is a number of functions that help detect and extract data from JSON/XML in expressions: