Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 1 Monat, 2 Wochen
Letzter Beitrag:
vor 1 Monat, 1 Woche
Beteiligte Autoren:
willy hermans, Ned!, M-K

HTTP request - Logging in to Quality guard

Startbeitrag von willy hermans am 27.11.2017 09:49

Hello,

I use this code for connection to a testportal

sURL is string
sURL="http://test.qguardportal.be:8443/v2/recipeinfo/21";
sHTTPRequest is httpRequest
//sHTTPRequest..Header["Accept: application/json"]
sHTTPRequest..Header["X-API-TOKEN:4723152"]
sHTTPRequest..URL=sURL
//sHTTPRequest..Method=httpPost
sHTTPRequest..Content=sURL
sHTTPRequest..ContentType="application/json"


cMyResponse is httpResponse = HTTPSend(sHTTPRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
EDT_NoName1 = cMyResponse..Content
END



This is the respons



Error 405


HTTP ERROR: 405
Problem accessing /v2/recipeinfo/21. Reason:
Method Not Allowed
Powered by Jetty:// 9.3.11.v20160721



So Metod not allowed.
Am I doing something wrong.

Greetings
Willy Hermans

Antworten:

Hi,

I guess your question is that you cannot retrieve information from a page and this is the error you get?
In that case you are using the wrong httpmethod ( httpget, httppost, etc)

Scroll to the method part in this doc for more information:
https://doc.windev.com/en-US/?1000021158&name=TYPE_httpRequest

von M-K - am 30.11.2017 11:23
Hello,


Meanwhile, something has already evolved.
I use the following code.

sURL is string
sURL="http://test.qguardportal.be:8443/v2/recipeinfo/21";
sHTTPRequest is httpRequest
sHTTPRequest..ContentType="application/json"
sHTTPRequest..Header["X-API-TOKEN: 4723152"] --> This expression returns an unused value
//sHTTPRequest..header["Accept: application/json"]

sHTTPRequest..URL=sURL
sHTTPRequest..Method=httpGet

cMyResponse is httpResponse = HTTPSend(sHTTPRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
EDT_NoName1 = cMyResponse..Content
END


The result is :
{"error":"You do not have access to this resource."}


The provider of the service tells :
From the curl you get after the 'try it out':
curl -X GET - header 'Accept: application / json' - header 'X-API-TOKEN: 4723152' 'http://www.qguardportal.be:8443/v2/recipeinfo/21'

You have to take the last url:
http://www.qguardportal.be:8443/v2/recipeinfo/21

And then you have to add 2 more headers:
Accept: application / json
X-API TOKEN: 4723152

With best regards
Eline Desmet

Analyst / PO


The given info is for test only so it is not a specific account

So I think the error is in the line
sHTTPRequest..Header["X-API-TOKEN: 4723152"]

Anyone an idea.

Thanks already
Willy Hermans

von willy hermans - am 06.12.2017 07:04
Hi Willy,

This code should do it for you. You were nearly there...


sURL is string
sURL="http://test.qguardportal.be:8443/v2/recipeinfo/21";
sHTTPRequest is httpRequest
sHTTPRequest..ContentType="application/json"
sHTTPRequest..Header["X-API-TOKEN"] = "4723152"
sHTTPRequest..Header["Accept"] = "application/json"


sHTTPRequest..URL=sURL
sHTTPRequest..Method=httpGet

cMyResponse is httpResponse = HTTPSend(sHTTPRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
EDT_NoName1 = cMyResponse..Content
END


Thanks
Ned

von Ned! - am 06.12.2017 10:06
Thank you very much.
This seems to werk perfectly

Willy Hermans

von willy hermans - am 06.12.2017 13:01
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.