FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
[WB 22] Get a JSON response in API rest call
[WB 22] Get a JSON response in API rest call
Débuté par Victoria Caballero, 15 avr. 2018 18:26 - 2 réponses
Connectez-vous…
Victoria Caballero
#1
Posté le 15 avril 2018 - 18:26
Hi everybody,
I need some help from some API rest gurus.
I cannot figure out yet how to get a Response in JSON format.
This is my code now:
oRequest is httpRequest
oResponse is httpResponse
oRequest..URL = "
https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi
"
oRequest..Method = httpPost
oRequest..ContentType = "application/json"
// Request content
oRequest..Content = [
{
"test": false,
"language": "en",
"command": "GET_PAYMENT_METHODS",
"merchant": {
"apiLogin": "pRRXKOl8ikMmt9u",
"apiKey": "4Vj8eK4rloUd272L48hsrarnUA"
}
}
]
// Runs the request and retrieves the response
oResponse = HTTPSend(oRequest)
So "oResponse" has a property "ContentType" but this one it is ReadOnly... cannot be changed.
The result I get looks like this:
https://www.screencast.com/t/tGWpVfUTF
.
So I have tried this:
vResultVar is Variant = JSONToVariant(oResponse..Content)
but I get the error message:
JSONToVariant function called.
Invalid JSON format
So it seems the result it is not in JSON format
.
I do not know how to indicate in my code that the result should be in JSON format. Should be something like "Accept: application/json" but I do not know where can I place this in my code if possible.
TIA.
Regards
Signaler
0
0
Victoria Caballero
#2
Posté le 15 avril 2018 - 00:11
I answer myself... I have read the help again and I figure out I could use this in the Header property :
oRequest..Header["Accept"] = "application/json"
and it works!!
Signaler
0
0
Allard
#3
Posté le 15 avril 2018 - 19:42
Hi,
Looks to me that the result is XML
Json ==> Javascript Object Notation
It has the curly brackeds and stuff not the < > Tag structure
regards
Allard
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte