StoreOnce Backup Storage

Storeonce API authentication

 
SOLVED
Go to solution
Sean-PA
Occasional Advisor

Storeonce API authentication

I am trying to script some reports using powershell with the Storeonce api and I am struggling on even getting connected. I'm using the invoke-restmethod cmdlet and my code looks like this:

$username = 'myusername'
$password = 'mypassword'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$resp = Invoke-RestMethod -Method Post -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType 'application/json' -Uri 'https://mystoreonce.domain/pml/login/authenticatewithobject/'

The error I'm getting is:

Invoke-RestMethod : No content to map due to end-of-input

 

I've googled that error with no luck. Any ideas what I'm missing or doing wrong?

1 REPLY 1
Sean-PA
Occasional Advisor
Solution

Re: Storeonce API authentication

Figured it out:

$username = 'myusername'
$password = 'mypassword'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

Invoke-RestMethod -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType 'application/json' -Uri 'https://mystoreoncefqdn/api/v1/data-services/cat/stores'

Basically, I dont need to authenticate to the uri given in the curl i just go right to the api endpoint I need and include auth info in the header.