1. Daniel Mullings
  2. PowerBuilder
  3. Tuesday, 6 February 2024 18:46 PM UTC

Odd issue that's been plaguing me for awhile now.

I'm trying to authenticate against ping access (grab a token) so that I can call a rest api with that token.

Here's the powerbuilder code: 

Constant Integer 		SECURE_PROTOCOL_TLS = 5 //Set TLS to 1.2 (5)	
//Start the ping access token retrieval
ls_auth_body = '{"userId":"' +  as_username  + '", "password": "'+ as_password + '"}'
lnv_HttpClient = Create HttpClient
lnv_HttpClient.Clearrequestheaders( )
lnv_HttpClient.SetRequestHeader('Content-Type', 'application/json')
lnv_HttpClient.SecureProtocol = SECURE_PROTOCOL_TLS
lnv_HttpClient.SetRequestHeader('Proxy', 'http://myproxy.com:myport')
lnv_HttpClient.Timeout = Long(gnv_app.is_webpingtimeout) // tried 5 - 30 seconds
ls_all_req_headers = lnv_HttpClient.GetRequestheaders()
li_rc = lnv_HttpClient.SendRequest("POST", as_pingurl, ls_auth_body)

li_rc returns a -4 on our VM, but using a powershell script to access the same as_pingurl works flawlessly.

Here's the powershell code:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ContentType = "application/json" # Add the content type
$Method = 'POST'
$LoginUrl = "as_pingurl"
#### Ping Access #######
$body = @{
    userId="userid"
    password = "password"
} | ConvertTo-Json
$pingProps = @{
    Uri         = $LoginUrl
    Method      = $Method
    ContentType = $ContentType
    Body        = $body
}
try{
    $pingResponse = Invoke-RestMethod @pingProps
    Write-Host $pingResponse
}catch{
$err =$_.Exception
Write-Host $err.Response
$pingResponse = ""
}

The powershell code works fine and doesn't designate a proxy.

Am I missing something in the header that needs to be added to the powerbuilder code?

This code works fine from my desktop, but it seems the VM needs something else to make it work.

I think the powershell code is using the default proxy set via (netsh winhttp set proxy) but powerbuilder doesn't seem to be using that and it seems to be ignoring the proxy value set in the request header.

Our network guys are saying the requests are being blocked, but not sure why since everything that's needed is open.



There are no replies made for this question yet.
However, you are not allowed to reply to this question.