jQuery call to get beacons list from Estimote cloud REST API

Hi,
How can I retrieve my accounts associated beacons list from https://cloud.estimote.com/v1/beacons REST api?

I am using this way but I am always facing cross-origin errors:

$.ajax({
                    url: 'https://cloud.estimote.com/v1/beacons',
                    type: 'GET',
                    xhrFields: {
                        withCredentials: true
                    },
                   headers: {
                       'Authorization': 'Basic ' + btoa('myAppID:myAppSecret')
                   },
                    crossDomain: true,
                    accepts: {
                        json: 'application/json'
                    }
                }).done(function (data) {
                    console.debug(data);                
                }).error(function (httpRequest, textStatus, errorThrown)
                {
                    console.debug("errorThrown=" + errorThrown);
                });

I tried for few hours with lots of different ways but never got to it.

Thanks!

Sylvain Audet
MyDevPartner.com

You cannot make an AJAX call in a web-browser from one domain (e.g., myserver.com) to another (e.g., cloud.estimote.com), that’s by design. You can read more about it here:

You should still be able to make the request to Estimote Cloud API outside a web-browser, e.g., from your backend.

What do you want to use the list of beacons for?

Thanks for your reply Piotr.
You are right, we’d rather change the approach to call the API from our backend instead of front-end ajax call.

The idea is to pre-populate our DB with our devices available from the Estimote cloud.

-Sylvain