[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] How to retrieve http status of last request



I had exactly the same issue and the simple answer for me was to switch from http_string to http_req.  http_string is intended for ease of use but deals with errors by issuing an exception message which will not give you access to the error payload.  Sitting to http_req() allowed me to access everything I needed.

httpResponse = HTTP_req( 'POST'
                       : url
                       : *Omit
                       : response
                       : *Omit
                       : requestData
                       : 'application/json');   

   

On Jul 17, 2020, at 12:06 PM, Richard la Croix <richard.lacroix@xxxxxxxxxxx> wrote:

Hi everybody,

probably I am overlooking something, but I can't find how to retrieve the http status code of the last http request I made,

I do a http_string() with 'POST'

and after  I do:

hmErrMsg = http_error(hmErrNo: hmRspCode);

hmErrNo and hmRspCode are both 10i fields.

hmErrMsg and hmErrNo get the values that I also see in the debug log file (see below).
I understood that hmRspCode would contain the http response code, in this case 401, however the value is 0.

Also, the webservice returns a JSON structure together with the 401 which I don't receive as the result of the http_string() call. I assume HTTPAPI cancels processing after a httpStatus >= 400.

Anybody any suggestions?

Thanks in advance,
Richard


From the log file:

recvresp(): entered
HTTP/1.1 401 Unauthorized
Server: nginx/1.17.8
Date: Fri, 17 Jul 2020 15:11:31 GMT
Content-Type: application/json
Content-Length: 72
Connection: keep-alive
Cache-Control: no-store
X-XSS-Protection: 1; mode=block
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15724800; includeSubDomains
X-Content-Type-Options: nosniff


SetError() #13: HTTP/1.1 401 Unauthorized
recvresp(): end with 401
recvdoc parms: identity 72
SetError() #36: This page requires a user-id & password
AuthPlugin_mustReceiceAuthErrorPage(): entered
http_close(): entered



--

--
Richard la Croix
Software Engineer

 

richard.lacroix@xxxxxxxxxxx
T +41 41 767 81 53

 

Hapimag AG | Sumpfstrasse 18
6312 Steinhausen | Schweiz
www.hapimag.com
    
Eingetragen: Handelsregister des Kantons Zug, Firmennummer/UID: CHE-101.391.790,
MWST.-Nr.: CHE-101.391.790 MWST, CEO: Hassan Kadbi



  P Please consider the environment before printing this email
 
 
--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi

-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi