Você sabia que o Bot Livre também oferece acesso gratuito hospedado problema de rastreamento para seu próprio website ou aplicativo para celular?
SDK and Web API

JSON web API

por pavelk postado Oct 24 2018, 12:05

Hello,

I'm trying to fetch a list of instances using JSON endpoint:

var request = new XMLHttpRequest();
request.open('POST', 'https://www.botlibre.com/rest/json/get-all-instances', true);
request.setRequestHeader('Content-Type', 'application/json');
var json = JSON.stringify({'application': '721375371321663745'});
request.onreadystatechange = function() {
console.log(request.responseText);
};
request.send(json);

However, I got the following response:

Missing application id. You can obtain an application id from your user page.

 

Am I doing something wrong? What is the correct way to pass an application id to this JSON endpoint?

The same request body format works fine with JSON "/rest/json/chat":

var request = new XMLHttpRequest();
request.open('POST', 'https://www.botlibre.com/rest/json/chat', true);
request.setRequestHeader('Content-Type', 'application/json');
var json = JSON.stringify({
"application": "721375371321663745",
"instance": "909409",
"message": "Hello"
});
request.onreadystatechange = function() {
console.log(request.responseText);
};
request.send(json);


by admin posted Oct 25 2018, 9:35

For the JSON API any attribute (from the XML API) requires an @ prefix (except for the /chat API).

i.e.

var request = new XMLHttpRequest();
request.open('POST', 'https://www.botlibre.com/rest/json/get-all-instances', true);
request.setRequestHeader('Content-Type', 'application/json');
var json = JSON.stringify({'@application': '721375371321663745'});
request.onreadystatechange = function() {
console.log(request.responseText);
};
request.send(json);

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2225, today: 4, week: 11, month: 18

by pavelk posted Oct 26 2018, 7:07

It works, thanks a lot!


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2215, today: 6, week: 10, month: 17

Id: 24737015
Tags: api, javascript, json
Postado: Oct 24 2018, 12:05
Respostas: 2
Pontos de vista: 2299, hoje: 6, semana: 10, mês: 15
0 0 0.0/5