Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a webapi with parameters
Message
De
05/03/2018 11:30:29
 
 
À
05/03/2018 08:12:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Divers
Thread ID:
01658531
Message ID:
01658540
Vues:
60
>Good day all, in my current project I need to call a webapi using GET to obtain a json with specific information, I'm already opening the url and its responding like I'm not authenticated, I don't know how to add in the header call the parameters, The example I have for it is like the following:
>The Authorization: bearer -> is followed by a long token string that I already have.
>
>curl -X GET --header 'Accept: application/json' --header 'Authorization: bearer eyJ0..very..long..token..qg' 'https://api-xxinvoicing-co-.com/api/xxnasw/companies'
>
>I'm doing this:
>
>
>    local cKey, cdom
>    cKey="dd...very..long..token"
>    cdom="https://api-xxinvoicing-co-.com/api/xxnasw/companies"
>    LOCAL loXMLHTTP as "MSXML2.XMLHTTP" 
>    loXmlHttp = CREATEOBJECT("MSXML2.XMLHTTP") 
>
>    WITH loXmlHttp 
>
>        .setRequestHeader("Accept", "application/json") &&&getting error here
>        .setRequestHeader("Authorization", "bearer") &&&getting error here
>        .setRequestHeader("bearer", ckey) &&&getting error here
>        .open("GET", cdom, .F.) &&no error
>
>        .Send()  &&no error
>ENDWITH 
>
>MESSAGEBOX(loXmlHttp.responseText,0,"responsetext") &&message not authenticated
>
>
>
>Please let me know how to add the token to the header to be recognized as already authenticated. T.I.A.

.setRequestHeader() must be executed between an .open() and a .send(): that is, first you open, then you set the headers, and only afterward you send the call.
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform