HTTPAPI Error for Ocp-Apim-Subscription-Key

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
KKT
Posts: 8
Joined: Thu Apr 28, 2022 8:05 am

HTTPAPI Error for Ocp-Apim-Subscription-Key

Post by KKT »

Hi,
I am using HTTPAPI Ver 1.42 released 2020-10-12 .
We have a requirement where we need to post information to Azure. For this we are using http_response, also there is an Ocp-Apim-Subscription-Key that needs to be passed to connect to server. Previously we were using 'x-functions-key:' and it was working fine. Now we moved to Ocp-Apim-Subscription-Key and I am not able to connect to the server getting "Timeout occurred while trying to connect to server! " error. Please find below the code snippet.
Could you please tell me where I am going wrong?

http_debug(*On: '/tmp/httpdebug.txt');

http_xproc( HTTP_POINT_ADDL_HEADER : %paddr(addSpecialHeaders) );

Monitor;
http_response = http_string('POST':Url:P1data:'application/json');
On-Error;
errorMsg = http_error( xErrorNo );
http_comp('Error! xErrorNo: ' + %char(xErrorNo) +
' errorMsg: ' + errorMsg );

EndMon;

PaddSpecialHeaders...
P B
DaddSpecialHeaders...
D PI
D headersToAdd 32767a varying
*

headersToAdd = 'x-functions-key:' + 'uniquekey'
+ CRLF ;

Now it is changed to
headersToAdd = 'Ocp-Apim-Subscription-Key:' + 'uniquekey'
+ CRLF ;


Return;
PaddSpecialHeaders...
P E

The Debug log generated is as below:
HTTPAPI Ver 1.24 released 2012-01-23
OS/400 Ver V7R3M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: XXX.COM
DNS server found: 10.250.1.1
DNS server found: 10.250.2.2
DNS server found: 10.178.200.20
https_init(): entered
--------------------------------------------------------------------
Dump of local-side certificate information:
--------------------------------------------------------------------
SetError() #7: Timeout occurred while trying to connect to server!
http_close(): entered
************End of Data********************
Scott Klement
Site Admin
Posts: 635
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTPAPI Error for Ocp-Apim-Subscription-Key

Post by Scott Klement »

Either the server isn't running, or a firewall is blocking access, or you have the wrong URL, or something like that.

A header can't cause the connection to time out.
KKT
Posts: 8
Joined: Thu Apr 28, 2022 8:05 am

Re: HTTPAPI Error for Ocp-Apim-Subscription-Key

Post by KKT »

Yes, This was a firewall issue. Thanks!
Post Reply