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

Description

You are able to access Rest API through a PowerShell script. To access the Rest API for ElectricFlow 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 <URI> -Headers <Encoded-Username-Password> -ContentType "application/json" -Method <REST-HTTP-Method>

The uri will generally be in this format:

https://<ElectricFlow-domain>/rest/v1.0/<path>?<query>

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://<ElectricFlow-domain>/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 ElectricFlow'.

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

 

Function

Method

Path and Query

Add a New Property to a Property Sheet

Post

/rest/v1.0/properties/<name-of-property>?request=incrementProperty&<Query for Propertysheet>

Set a Property in a Property sheet

Put

rest/v1.0/properties/tester?<Query for Property sheet>&value=<value>

Get a Property

Get

/rest/v1.0/properties/<property Name>?<query>

Login

Post

/rest/v1.0/sessions?username=<Username>&password=<Password>

Get Job Details

Get

/rest/v1.0/jobs/{jobId}?request=getJobStatus

Publish Artifact Version

Post

/rest/v1.0/artifacts/{artifactName}/artifactVersions?<query>

Get Artifact Version

Get

/rest/v1.0/artifactVersions/{Artifact Name}

Create Job step

Post

/rest/v1.0/jobSteps?<query>

Get Server Status

Get

/rest/v1.0/server/status?<query>

Export

Get

/rest/v1.0/server?<query>

Import

Post

/rest/v1.0/objects?<query>

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

Have more questions? Submit a request

Comments

Powered by Zendesk