Chain multiple API requests in a single API poller in SAM
You can send an initial request to an API to get a value, and then save the value as a variable that can be passed to subsequent requests that are chained together in a single API poller. This is for APIs that involve tokens, sessions, or endpoint discovery.
For example, if an API requires tokens, the initial request can retrieve a token that is then passed along to headers of subsequent API requests to authenticate access to data. The VMware vCenter Inventory template uses this technique.
To see this functionality in action, watch API Pollers: When SNMP Won't Cut It.
You can save response headers for use as variables in subsequent requests, which can be helpful if you need to reuse cookies that come from set-cookie headers.
To chain multiple API requests in a single API poller:
-
Click Settings > All Settings > Manage API Pollers.
-
On the Manage API Poller page, click New, select the row for a node, and then click Create API Poller.
-
Select GET as the Method.
-
Click Configure to provide details about the API poller, such as a name, credentials, and thresholds; see Add API pollers in SAM for details. Click Save when finished.
-
Provide a header, if required.
-
Click Send Request.
-
When the response appears, click the Monitor () icon next to the value you want to use in subsequent requests (for example, a token needed to authenticate data).
-
In the next dialog box:
-
For "How should we store this value?" select "Use as a variable in subsequent request.
-
Enter a name for the variable.
In later requests, the value uses the following notation:
${varName}
. -
Click Save to close the dialog box.
-
-
To create another request in the same API poller, click Options () > Duplicate.
When the page displays a set of fields for the new request, you can use the variable defined in the previous request. In the following example, the variable is added to the URL.
-
Configure the new API request, as necessary, and then save changes. To add a new request to the existing requests, click Options > Duplicate again.