Welcome! Log In Create A New Profile

Advanced

[WB] different behavior when consuming REST webservices

Posted by pao 
pao
[WB] different behavior when consuming REST webservices
December 06, 2021 05:59PM
I'm having diferent behavior when consuming REST webservices, i will me try to explain my problem.
Option1:
HTTPCreateForm("FORM")
HTTPAddParameter("FORM","grant_type","bks_cookie")
HTTPAddParameter("FORM","client_id",p_CLIENTID)
HTTPAddParameter("FORM","assertion",P_COOKIE)

http_req is httpRequest
http_req.URL=P_WEB_SRV
http_req.IgnoreError=httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirection+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS+httpIgnoreRevocation
http_req.Method=httpPost
http_req.ContentType=MIME_TYPE
http_req.TimeOut=600000

http_res is httpResponse
http_res=HTTPSendForm("FORM",http_req)
HTTPCancelForm("FORM")
IF http_res.StatusCode<>"200" THEN
IF http_res.StatusCode=0 THEN
error(ErrorInfo(errFullDetails))
ELSE
error(http_res.StatusCode +" - "+http_res.Content)
END
RESULT False
END
RESULT True

Option2:
HTTPTimeOut(600000)
HTTP.IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
buff_json=""
buff_json="client_id="+URLEncode(p_CLIENTID)
buff_json+="&assertion="+URLEncode(P_COOKIE)
buff_json+="&grant_type=bks_cookie"
IF NOT HTTPRequest(P_WEB_SRV,"","",buff_json,MIME_TYPE) THEN
RESULT False
END
wht_res is Buffer=HTTPGetResult()
RESULT True

If I use option 1, the intended one because I need to control the statuscode, I don't have any status code and I always get No server response error. Check whether a HTTP server is present on the target computer.

I i use option2 a can get the result in JSON but i can't control the statuscode.

Does anyone have any idea about what can cause the difference in behavior?

Regards

Paulo Oliveira
.....I i use option2 a can get the result in JSON but i can't control the statuscode.

Sure you can
Httpgetresult can also return the HEADER (see options in help) and you will have the status code in that

From the top of my head, there is an example of that in wxreplication, in the communication protocol. Fabrice is using httprequest, then checking the status code of the answer, then using the answer.
pao
Re: [WB] different behavior when consuming REST webservices
December 07, 2021 09:43AM
My suspicion is that the way WEBDEV determines whether to use a PROXY or not is different from option1 to option2.
Does anyone know a way to check whether the default-defined PROXY is used or not in each option?

Regards

Paulo Oliveira
pao
Re: [WB] different behavior when consuming REST webservices
December 13, 2021 03:06PM
From our test if we use httprequest variables (Option1) the OS proxy configuration isn't used but if we use the httprequest function (Option2) it's used.

Anyone can confirm this?

Regards

Paulo Oliveira



Edited 1 time(s). Last edit at 12/13/2021 03:08PM by pao.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: