Develop own beacons manager

Hello,

I want to develop a beacons web manager for my own beacons. I found the Cloud API here, https://cloud.estimote.com/docs/#api-Devices-GetDevice

I tried with AJAX, but got the error :

XMLHttpRequest cannot load https://cloud.estimote.com/v2/devices/. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://***’ is therefore not allowed access.

This is the function I used:

function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var beacons = JSON.parse(this.responseText);
var txt = “”;
var x;
for (x=0; x < beacons.length; x++) {
console.log(beacons[x].shadow.id + “_” + beacons[x].shadow.name);
}
}
};

var myUrl=“https://cloud.estimote.com/v2/devices/”;

xhttp.open(“GET”, myUrl, true);
xhttp.setRequestHeader(“Access-Control-Allow-Origin”, “*”);
xhttp.setRequestHeader(“Authorization”, “Basic” + btoa(“AppID:AppToken”));
// xhttp.setRequestHeader(“Accept”, “application/json”);
xhttp.setRequestHeader(“Accept”,“application/json; charset=utf-8”);
xhttp.send();
}

Does anyone have any idea on this? Thank you

You should try it from the server side. It is not just enough with setting a header for Access-Control-Allow-Origin, their servers has to allow your domain. This usually happens when using headers other than basic headers.
Take a look at http://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work
for further reading see https://en.wikipedia.org/wiki/Cross-origin_resource_sharing and

There are plenty of managers for your beacons out there. beejuy dot com let’s you manage beacons and their content. beaconcontrol dot io/ is an open source software that allows you to do the same. pushmote, and other are good paid options with integrations to estimote and kontakt. I would recommend trying one of them first unless you are learning or trying to enter the beacon management market

Thank you jdelgado2002. Really helpful information.