PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → HTTP request - Logging in to Quality guard
HTTP request - Logging in to Quality guard
Débuté par willy hermans, 27 nov. 2017 10:49 - 4 réponses
Posté le 27 novembre 2017 - 10:49
HTTP ERROR: 405


Problem accessing /v2/recipeinfo/21. Reason:
Method Not Allowed
Powered by Jetty:// 9.3.11.v20160721
Posté le 30 novembre 2017 - 12:23
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/…
Posté le 06 décembre 2017 - 08:04
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
Posté le 06 décembre 2017 - 11:06
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
Posté le 06 décembre 2017 - 14:01
Thank you very much.
This seems to werk perfectly

Willy Hermans