Download as json

hi, I want to automatically pull specific information about the process + Project Variables in the project at regular intervals through the Octopus API interface : download as json , Can you help me with this?

Good morning @david.sun,

Thank you for contacting Octopus Support, welcome to the forums and great question on grabbing the deployment process JSON.

You may pull this directly from the API using the following URL (be sure to replace the URL, SpaceID, and ProjectID):

http://octopusinstanceURL/api/Spaces-x/deploymentprocesses/deploymentprocess-Projects-xxx

So you could pull this from a run a script step if you wanted to in a runbook which you could setup to run at regular intervals as you mentioned.

If you right click on the ‘Download as JSON’ button and select ‘copy link address’ or ‘open in new tab’ you will be able to see the JSON if you paste it into your browser, so you can grab the URL from whatever project you want from the UI for the runbook.

If you wanted it as a json file you could pipe the output of the deployment process to a .json file and attach it to the runbook as an artifact.

The variables you can get from this call:

http://octopusinstanceURL/api/Spaces-x/projects/Projects-xxx/variables

Hopefully that helps, let me know if you wanted anything further and we will do our best to assist.

Kind Regards,
Clare

How to add authentication information?

https://octopus.lifebyte.io/api/Spaces-1/projects/Projects-298/variables

Hi @david.sun,

Just stepping in for Clare while she’s offline, I’d be happy to help!

To authenticate with our API you will need to create an API Key and include that the API key in the request, either as a Header or Query Param: Octopus REST API | Documentation and Support

Once you have a key, you can provide it to the API in the following ways:

  1. Through the X-Octopus-ApiKey HTTP header with all requests. This is the preferred approach.
  2. As an apikey query string parameter with all requests. This should only be used for simple requests.

Check out our API examples to see this in action: API examples | Documentation and Support

Hope that helps but feel free to reach out with any questions at all!

Best Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.