Got a really bizarre problem with Invoke-RestMethod. I'm using it send a GET and include a cookie in the request:
$getEndpoint = "http://YYYYYYYYYYYYYY/clients/XXXXXX/dev"
$authheader = "auth_tkt=\""XXX"""
Invoke-RestMethod -Headers @{"cookie" = "$authheader"} -Uri $getEndpoint
If I look at the request in Fiddler then I see this:
GET http://YYYYYYYYYYYYYY/clients/XXXXXX/dev HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT; Windows NT 6.1; en-GB) WindowsPowerShell/4.0 Host: YYYYYYYYYYYYYY Connection: Keep-Alive
Where's the cookie gone? Someonewhere along the pipe the cookie is disappearing. Any ideas why? I'm assuming I'm misunderstanding something somewhere.
In case it matters, I have attempted a similar request from curl and it works without issue (i.e. it authenticates using the provided cookie and I get the response I'm expecting):
curl -H "cookie: auth_tkt=\"XXX" http://YYYYYYYYYYYYYY/clients/XXXXX/dev