更に当社の Platinum サービスして作り上げていきたいと思い自ボットのためにま
SDK and Web API

JSON web API

による pavelk 掲載 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: 2453, today: 0, week: 1, month: 26

by pavelk posted Oct 26 2018, 7:07

It works, thanks a lot!


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2415, today: 1, week: 3, month: 20

Id: 24737015
タグ: api, javascript, json
掲載: Oct 24 2018, 12:05
回答: 2
眺望: 2531, 今日の: 1, 週間: 3, 月: 25
0 0 0.0/5