- Daniel Mullings
- PowerBuilder
- Tuesday, 10 October 2023 11:15 PM UTC
I can successfully grab a ping access cookie from our authentication server using the httpclient object, but how do I setup a call to a rest service with that cookie?
My co-worker successfully does this in powershell using the System.Net.Cookie object and setting the attributes, then calls the rest service.
How can I emulate this in PB?
This is what it looks like in powershell:
$apibody = @{
Code = "Code"
Command = "commanddata"
} | ConvertTo-Json
$Cookie = New-Object System.Net.Cookie
$Cookie.Name = "PingAccessClient"
$Cookie.Value = $value | Out-String
$Cookie.Domain = "mydomain.com"
$Cookie.HttpOnly = $true
$Cookie.Secure = $true
$Cookie.Path = "/"
$WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$WebSession.Cookies.Add($Cookie)
$props = @{
Uri = "https://restcall.mydomain.com/getmyresponse"
Headers = $headers
ContentType = $ContentType
Method = 'POST'
WebSession = $WebSession
Body = $apibody
}
try{
$res = Invoke-RestMethod @props
$err = ""
}
catch{
$err =$_.Exception
$res = ""
}
Any help would be much appreciated.
Thanks.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.