API restfull avec authentification token Bearer
Bonjour,
J'ai une API à interroger en récupérant tout d'abord un token de type Bearer.
Après je lance une requête de type HTTPGET avec un paramètre de type JSON, afin d'avoir un résultat de type JSON.
J'ai réussi à récupérer le token Bearer, et le souci est que je n'arrive pas à récupérer le résultat de la deuxième requête paramétrée en utilisant le même token récupéré.
Le code est:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
//Envoi pour récupérer le token
login est une httpRequête
login.Méthode= httpPost
login.URL = "http:
../token"
login.ContentType= "application/json"
body est un JSON
body.name= Btn_user
body.password = Btn_pass
login.Contenu = body..FORMATJSON
Trace(body)
// Exécution de la requête
Token est une httpRéponse = HTTPEnvoie(login)
jtoken est JSON = Token..Contenu
Trace(jtoken)
Mafonction est une httpRequête
Mafonction.Méthode= httpGet
Mafonction.URL= "http://...................................................................../fonction"
Mafonction.ContentType= "application/json"
Mafonction.Entête["Authorization"] = "Bearer "+JSONVersVariant(jtoken)
Param_body est un JSON
Param_body.attribut = Saisie_attribut
Mafonction.Contenu= Param_body..FORMATJSON
Trace(Param_body)
// Exécution de la requête
Mafonction_reponse est une httpRéponse = HTTPEnvoie(Mafonction)
Fonction_resultat est JSON= Mafonction_reponse.Contenu
Info(Fonction_resultat) |
Avez vous une idée sur la manière à suivre pour envoyer un paramètre de type JSON dans une requête HTTPGET.
Merci.