UiPath Documentation
maestro-automate
latest
false
Maestro Automate user guide

Call an external API

Build a workflow step by step that calls an API with HTTP Request, then reshapes the response with Transform and Script.

What you build​

A workflow that calls an authenticated Representational State Transfer (REST) API, handles the response, and makes the extracted data available to the nodes after it. A REST API is a web service that other software can call over HTTP. The pattern applies to any system that exposes an HTTP API.

The steps use a public sample API, dummyjson.com, so you can follow them without an account or credentials. The workflow calls GET https://dummyjson.com/users/1, extracts the user's first name and email from the response, and returns the error details if the call fails. To use your own API later, replace the URL and add its authentication in step 2.

Before you start​

  • Nothing else for the example. dummyjson.com is public and needs no authentication.
  • For your own API: its base URL, endpoint path, and authentication details (API key, bearer token, or basic auth credentials).

Nodes used​

  • Manual Trigger: starts the workflow on demand.
  • HTTP Request: calls the REST API.
  • Transform: extracts the fields needed from the response.
  • Script: returns the error details on the HTTP Request's error path.

Steps​

Tip:

With a coding agent set up, you can skip the manual steps. Ask it:

Build a Maestro Automate workflow that starts manually with a userId, calls GET https://dummyjson.com/users/{userId} with an HTTP Request node, returns the user's name and email, and, if the call fails, returns the error details from a Script node on the error path.
Build a Maestro Automate workflow that starts manually with a userId, calls GET https://dummyjson.com/users/{userId} with an HTTP Request node, returns the user's name and email, and, if the call fails, returns the error details from a Script node on the error path.

Then open the workflow on the canvas, check it against the steps below, and test it. Set up your coding agent describes the setup.

1. Create a new workflow and add a trigger​

Create a project, as Your first workflow describes. The canvas opens with a Manual Trigger already on it.

2. Add and configure the HTTP Request node​

  1. Select the + on the output handle of the Manual Trigger, search for HTTP Request, and select it.

  2. In the properties panel:

    • Set Method to the appropriate verb (GET, POST, PUT, PATCH, or DELETE).
    • Enter the full URL of the endpoint.
    • Under Headers, add authentication and content-type headers.

    For the example, set Method to GET and URL to https://dummyjson.com/users/1. This public API needs no headers.

If your own API requires authentication, add one of the following headers.

For bearer token authentication:

Add a header with the key Authorization and the value Bearer {{ secret.apiKey }}. The secret. prefix reads the value from the secure variable store. The key is never pasted directly into the field.

For basic authentication:

Add a header with the key Authorization and the value Basic {{ secret.encodedCredentials }}, where encodedCredentials is the base64-encoded username:password string.

3. Extract the data you need​

  1. Select the + on the output handle of the HTTP Request node, search for Data Transform, and select it.
  2. In the properties panel, map the response fields you need from $vars.httpRequest1.output.body to named output variables.

For the example, the response from https://dummyjson.com/users/1 includes fields such as { "id": 1, "firstName": "Emily", "email": "emily.johnson@x.dummyjson.com" }. Map:

  • $vars.httpRequest1.output.body.firstName → userName
  • $vars.httpRequest1.output.body.email → userEmail

4. Add error handling​

  1. Select the HTTP Request node, open the Error handling tab, and turn on Enable error handling. An Error handle appears below the main output handle.
  2. Select the + on the Error handle, search for Script, and select it.
  3. In the Script node, return the error details from $vars.httpRequest1.error. The returned message appears in the execution trace:
const error = $vars.httpRequest1.error;
return {
  message: "Error raised: " + error.message,
  status: error.status
};
const error = $vars.httpRequest1.error;
return {
  message: "Error raised: " + error.message,
  status: error.status
};

5. Test and debug​

Select Run Debug (▶) in the bottom toolbar of the canvas. In the execution trace:

  • Check the HTTP Request node's code output. 200 means success; 401 means your authentication is wrong; 404 means the URL is incorrect.
  • Check the Data Transform node's output to confirm the fields were extracted correctly.
  • To test the error path, temporarily set the URL to an invalid value and verify the error path executes.

Result​

The workflow calls the REST API, extracts the fields from the response, and returns the error details on the error path. The execution trace shows the HTTP status code and the extracted values for both paths.

Extend this workflow​

  • Handle pagination: if the API returns results across multiple pages, add follow-up HTTP Request nodes to fetch additional pages, branching with a Decision on whether the response includes a next-page cursor.
  • Write results to another system: after the Data Transform node, add another HTTP Request node or an integration node to push the data downstream.
  • Schedule it: replace the Manual Trigger with a Scheduled Trigger to run the workflow on a regular interval.

Next steps​

Was this page helpful?

Connect

Need help? Support(opens in new window)

Want to learn? UiPath Academy(opens in new window)

Have questions? UiPath Forum(opens in new window)

Stay updated