Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Accessing vCO REST API with PowerShell?

$
0
0

I am trying to call vCO workflow through REST API using PowerShell Invoke-RestMethod command, but I am having issues with HTTP authentication.

 

My PowerShell code looks like this

 

$username = 'thakala'
$upassword = 'foobar'
$auth = $username + ':' + $upassword
$Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth)
$EncodedPassword = [System.Convert]::ToBase64String($Encoded)
$headers = @{"Authorization"="Basic $($EncodedPassword)";}
Invoke-RestMethod -uri https://vco:8281/api/workflows/9ea59e9b7e1442a890b94c1f30335b20/executions/ -Headers $headers -Method Get

 

but when I run this I get following error

 

 

Invoke-RestMethod : HTTP Status 401 - The HTTP token has invalid syntax!

type Status report

message The HTTP token has invalid syntax!

description This request requires HTTP authentication (The HTTP token has invalid syntax!).

JBossWeb/2.0.1.GA

At line:13 char:1

+ Invoke-RestMethod -uri https://vco:8281/api/workflows/9ea59e9b7e1442a890b94c1f30 ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

 

so I guess something is wrong with my authentication method, any ideas what?


Viewing all articles
Browse latest Browse all 6251

Trending Articles