when i run the following cURL against my installation, I only get a limited set of objects.
curl --header “X-Octopus-ApiKey: API-XXXXXXX” https://octopusURI/api/environments//machines
I’m trying to build a script that will allow me to add a “target” scope and need the ID of a machine in order to do this successfully. However, when I try to poll all the machines, my “where Name = X” logic fails to find the deployment target.
Thanks for reaching out!
When you get a set of results from the Octopus API, if it has more than 30 items on it, It’ll only give you the first 30 and on the “Links -> Page.next” property of the JSON you get with those 30 results you’ll find a link to go to the next set of 30. You can use a FOR look to keep looping until you cannot find a “Page.next” link, meaning you’ve reached the last page.
Alternatively you could do your initial
/api/machines/all to get all machines from all Environments, and then filter as needed.
Hope that helps,