PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WEBDEV 2024 → API Authenticate
API Authenticate
Débuté par Mister RUAN, 20 fév. 2017 09:12 - 1 réponse
Membre enregistré
208 messages
Popularité : +1 (1 vote)
Posté le 20 février 2017 - 09:12
Good Day

I have an API where the AuthKey is in the header. How would I specify that in my code? I have tried to use the Header function but it doesn't allow me to do so.

cMyRequest is restRequest
cMyRequest..URL = "https://URLtoGetData"
cMyRequest..Method = httpGet
cMyRequest..Header[AuthIdentify("ApiKey 123456789")]


cMyResponse is restResponse = RESTSend(cMyRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
Info(cMyResponse..Content)
END


Tested on Postman and this is the code in HTML

GET htmltogetdata HTTP/1.1
Host: partofhtml
Authorization: ApiKey 123456789
Cache-Control: no-cache
Postman-Token: 52d789af-4959-91bb-fee5-02c358551e52

Thanks
Posté le 20 février 2017 - 23:17
With the Microsoft graph api I have used httpSendForm, this has a field for additional header entries and this has worked for me for the authentication tokens once they have been granted.


i.e.

IF HTTPSendForm("formName",URLString,httpPost,"",sToken,"text/plain")=True THEN

Where sToken = "Authorization: Bearer "+sTokenAcc