I am trying to make an API request in Powershell.
The curl command that works:
curl -k -v -X GET -H "Cookie: customer=<valueA>;JSESSIONID=<ValueB>" -H "Accept: application/json" https://someurl.net/path/path
I Tried:
$session = New-Object Microsoft.Powershell.Commands.WebRequestSession
$cookie = New-Object System.Net.Cookie
$cookie2 = New-Object System.Net.Cookie
$cookie.Name = "customer"
$cookie.Value = "<valueA>"
$cookie.Domain = "https://someurl.net"
$cookie2.Name = "JSESSIONID"
$cookie2.Value = "<valueB>"
$cookie2.Domain = "https://someurl.net"
$session.Cookies.Add($cookie, $cookie2);
Invoke-WebRequest -Uri "https://someurl.net/path/path" -Method Get -WebSession $session -Headers @{"accept"="application/json"}
This should return a json payload. Any help is appreciated.
-ContentType 'application\json'. Are your domains valid?