KBEC-00373 - Examples of using the Rest API through Powershell


You are able to access Rest API through a PowerShell script. To access the Rest API for CloudBees CD (CloudBees Flow) requires the domain name for the URI and a User.

All Scripts require the command Invoke-RestMethod, with the parameters: URI, headers, content type and method.

It should be in the following format.

Invoke-RestMethod -uri  -Headers  -ContentType "application/json" -Method

The uri will generally be in this format:


The Header will be generated earlier in the Powershell script. It will contain the encoded Username and Password.

Method will follow REST standards of “Get, Post, Put, or Delete”

The content type should be set to “application/json”

Query varies by which parameters you use. To find details on all the parameters used for a specific function or method, please visit: https:///rest/doc/v1.0/

For an example of a PowerShell script, please download ‘example-script.ps1’.

For more details on the methods used, please see ‘Using Powershell to call REST API of CloudBees CD (CloudBees Flow)’.

Below are a series of examples on the format of some the API functions

FunctionMethodPath and Query
Add a New Property to a Property SheetPost/rest/v1.0/properties/?request=incrementProperty&
Set a Property in a Property sheetPutrest/v1.0/properties/tester?&value=
Get a PropertyGet/rest/v1.0/properties/?
Get Job DetailsGet/rest/v1.0/jobs/{jobId}?request=getJobStatus
Publish Artifact VersionPost/rest/v1.0/artifacts/{artifactName}/artifactVersions?
Get Artifact VersionGet/rest/v1.0/artifactVersions/{Artifact Name}
Create Job stepPost/rest/v1.0/jobSteps?
Get Server StatusGet/rest/v1.0/server/status?

Many of these functions contain optional Flags and Queries. Please see the Rest API details to see these optional flags.

Have more questions?


Please sign in to leave a comment.