Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Connecting to REST based web service with powershell

$
0
0

I'm trying to query data from REST based web service with powershell. I have verified with Firefox restclient that the url and credentials I'm using are working:

I tried the same thing with powershell:

$user = "abc@def.com"
$pass= "qwerty"
$uri = "http://cmdb.server.local/company/connectors/rest.svc/asset?options=type=embedded&select=Asset[AssetTag,DeviceName,ResponsiblePerson,Model,Location,OS],Model[HWCategory,Manufacturer,Name,Type]&filters=Asset.Status
 ne Removed"

$secpasswd = ConvertTo-SecureString $user -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($pass, $secpasswd)
Invoke-RestMethod -Uri $uri -Method GET -Credential $cred -ContentType "application/xml"

But I just get the error message below:

<StatusCode>403</StatusCode>
<Description>Forbidden</Description>
<Details>Authentication failed: Authorization header is missing</Details>

The credentials are the same used with firefox/restclient.




Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>