Greg James

Powershell Invoke-WebRequest with API 2.1

Discussion created by Greg James on Jun 26, 2017
Latest reply on Jun 26, 2017 by Ivan Armendariz

## API Info
$apiRoot = "https://api.samanage.com"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", 'application/vnd.samanage.v2.1+json')

$contentType = "application/json"

 

## Get SAM IDs for all users of that page
$script:SAM_Results = Invoke-WebRequest -Uri "$apiRoot/users.json?per_page=100" -Header $creds -Header $headers -ContentType $contentType -Method Get

 

I am having issues figuring out where to put a token:  Example below:

 

“X-Samanage-Authorization: Bearer AAAZWV0YXkubmF0YW4rNUBzYW1hbmFnZS5jb20hbGciOiJIUzUxMiJ9.eyJ1c2VyX2ljIjoxMjU2OTQzLCJnZW5lcmF0ZWRfYXQiOiIyMDE3LTA2LTA3IDA5OjE3OjI5In0.j_H15qzJJr9vXGAHCThLEOQrE9GGbjMxZJOs5zAf_iqaGqxlIOAmvPpBx0td_C3r7dliAfXXIgdqhZHVoK1KTwAzd1

 

Any help would be appreciated.

Outcomes