HTTP as an action

This section demonstrates how to use HTTP as an action within Quickwork to interact with APIs that are not directly available as pre-built connectors on the platform.

Consider a scenario wherein the requirement is to retrieve current, forecasted, and historical air quality data for any location worldwide based on specific triggers.

Pre-requisites

  • Access to Quickwork.
  • An account in Rapid to access API details for Air Quality, including the endpoint URL, request parameters, and headers necessary to retrieve air quality data for a specified latitude and longitude.

Configuring the HTTP action

  1. In Quickwork, go to the journey configuration manager.
  2. Set up a journey where the journey is triggered using HTTP.
  1. Setup HTTP action:

    1. In actions, choose HTTP and then select the action Send new request.
    2. In the Request name field, input a descriptive name.
  2. Configure request details:

    1. Since we are interacting with an API that requires JSON, select application/json for Request content type.
    2. Based on the API documentation, which uses the GET method, set the method to GET for the Request HTTP method.

  3. Open this RapidAPI link, and click Subscribe to Test. You can select the Free plan for testing purposes.

  4. Copy the API endpoint URL provided in the API documentation of Air Quality.

  1. Paste the URL into the Request URL input field.
  1. Note that the latitude and longitude are specified after the '?' in the URL. Copy these values.
  1. Since there are two parameters, click on Add New Item. Then, insert these values into the Param name and Param Value fields for Item 1 and Item 2 respectively.
  1. Since the API requires headers (such as API keys or authentication tokens), copy them from the API documentation and paste them into the Request headers field. There are two headers, hence click Add New Item.
  1. Choose JSON as the Response content type to handle JSON formatted data from the API.

Testing the HTTP action

  1. After configuring the HTTP action, click Save & Start to activate the journey.

  2. Trigger and verify:

    1. Use the trigger configured in your journey to initiate the action. For this setup, go to the Journey tab and click on the URL.
    2. Go to the Output tab in History to view the detailed response from the HTTP action. This response should list the air quality details of the specified latitude and longitude based on the Air Quality API.

This section highlighted how HTTP actions can be strategically used in Quickwork to fetch data from external APIs, such as fetching air quality details. This method can be replicated with any API to perform various operations, including updates and deletions, thus enhancing the versatility and utility of your automation strategies.

Troubleshooting

  • Authentication errors: Ensure that the API key or token is entered correctly.
  • Incorrect URL or parameters: Double-check the endpoint URL and the required parameters. Ensure they match exactly what the API documentation specifies.
  • Method mismatch: Confirm the HTTP method required by the API. Update the method in the journey to align with the API's requirements.
  • Content-type issues: Verify that the response content-type matches the format expected by the API, for example, application/json.
  • Response handling errors: Review the API documentation to understand the response structure. Adjust the data parsing logic in the journey to correctly extract and use the data.
  • Timeout errors: To prevent your external systems from timing out during API calls, ensure you use a Try-catch block to manage these scenarios effectively.

✏️ Tips and recommendations

  • Always refer to the latest API documentation for accurate and up-to-date information on endpoints, parameters, and usage limits.
  • Implement comprehensive error handling in your journeys to gracefully manage API errors. Use conditional logic to handle different status codes and responses.
  • Before going live, test your HTTP actions extensively with all expected inputs to ensure they handle edge cases and errors as expected.
  • When setting up journeys that interact with external APIs, parameterize your requests to make them dynamic and adaptable to varying inputs.

📚 Additional resources

Introduction to HTTP
Using HTTP as a trigger