UiPath Documentation
integration-service
latest
false
Integration Service user guide

Chaining requests with Next resource

Run a second Connector Builder resource automatically after the first one completes, using the first response, to build activities that need more than one API call.

Some provider APIs don't return what you need in a single request. To download an attachment, for example, you might first request the record that holds the file ID, and then request the file itself.

Next resource handles these cases. When a resource has a next resource, Connector Builder sends the next resource's request automatically after the first request completes, and passes the first response to it.

How a chain runs​

  1. The resource sends its request and receives the response.
  2. The next resource sends its request. Its scripts can read the response body and headers of the previous request.
  3. If the next resource also has a next resource, the chain continues.
  4. The activity returns the response of the last request in the chain.

The activity's output fields are based on the response of the last resource in the chain.

Each request in the chain reuses the path variables, headers, and query parameters of the original request.

Setting a next resource​

  1. In Connector Builder, open your custom connector and select the resource that sends the first request.
  2. Select the Advanced tab.
  3. In Next resource, search for the resource to run next by its method or path, and then select it. A resource can't be its own next resource.
  4. Save your changes.
Note:

The resource you select as the next resource is still listed as its own activity, unless you hide it.

To use the previous response, add a pre-request script to the next resource on its Scripts tab. For details on scripts, see Scripts.

Using the previous response​

The pre-request script of the next resource can read the following variables:

VariableAccessDescription
request_previous_responseReadResponse body of the previous request in the chain. null if the resource doesn't run as part of a chain.
request_previous_response_headersReadResponse headers of the previous request in the chain. null if the resource doesn't run as part of a chain.
request_previous_vendor_pathReadThe path of the previous request in the chain. null if the request isn't part of a chain.

For example, the first resource gets a record that holds a file ID, and the next resource downloads the file. The pre-request script of the next resource reads the file ID from the previous response and adds it to the request path:

var previous = request_previous_response || {};

done({ request_vendor_path: '/files/' + previous.file_id + '/content' });
var previous = request_previous_response || {};

done({ request_vendor_path: '/files/' + previous.file_id + '/content' });

The path and the file_id property depend on your provider's API.

Limits​

  • A chain can include up to five requests, counting the first one. A longer chain fails with the error Resources chaining cannot exceed more than 5 calls.
  • A chain stops after a request that streams its response. The resources set after it don't run.
  • How a chain runs​
  • Setting a next resource​
  • Using the previous response​
  • Limits​

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