Hi,
What's the best practice of doing follow up requests in a protocol based on a previous response. I've looked trough the DataMiner Connector Integration: HTTP Basics course but it barely touched on the subject.
The element is communicating with the devices REST API.
A first request: GET /inputs - retrieves basic info about all input devices, this I use to populate a table.
Then to get more info the API exposes a /input/:id/status endpoint which I want to call for each input.
What's the recommended way of doing those second requests?
Hi Robin, first of all maybe check if there is no option that can be added to the initial GET /inputs to let it also return all details instead of only the basic list. On some APIs that option exists.
If above is not possible you'll indeed need to send subsequent requests to retrieve the detailed information about each input. One way to do that is as follows:
- retrieve the list of all inputs with GET /inputs
- parse the response in a QAction and store the ID of all inputs in a queue. This can be a private field in a non-static QAction.
- take the first ID in the queue, and set it to a new parameter
- the set on a parameter triggers a new HTTP session (trigger > action > group > session)
- parse the response of that single input
- while there are still items on the queue, repeat steps 3-6