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  -Headers  -ContentType "application/json" -Method

The uri will generally be in this format:

https:///rest/v1.0/?

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 ElectricFlow’.

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/?
LoginPost/rest/v1.0/sessions?username=&password=
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?
ExportGet/rest/v1.0/server?
ImportPost/rest/v1.0/objects?

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

Have more questions?

0 Comments

Please sign in to leave a comment.