Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Json request

I would like to make a request to the Appery api using a $.getJSON request. I have attempted the following but get a:

{"code":"DBSQ002","description":"database id not specified"}

Although the database is specified in the request how is this acheived correctly using jquery?

code:

function restTest()
{

$.getJSON("https://api.appery.io/rest/1/db/colle...?",
{
'X-Appery-Database-Id': 'XXXXXXXe4b0747d4efdf493',
'type': 'get',
'dataType': 'json',
'contentType': 'application/json',
},
function(data) {
alert(data);
});

}

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Json request

Hi,

I have managed to get this working on the localhost with the help of stackoverflow. I would value your comments on this! Will I have problems with this after I publish the web site or will this continue to work even without authorisation. If it doe's then I hope others will benefit from this code if not doh!

function testRest() {

xhr = new XMLHttpRequest();

$.ajax({
url: 'https://api.appery.io/rest/1/db/colle...?',
type: 'GET',
datatype: 'jsonp',
success: function (data) {
alert(JSON.stringify(data));
},
error: function (data) {
alert(JSON.stringify(data));
},
beforeSend: setHeader
});
}
function setHeader(xhr) {
xhr.setRequestHeader('X-Appery-Database-Id', 'xxxxxxxxe4b0747d4efdf493');
}

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

Json request

Hi Joe,

you are not setting the header, you are setting simple parameter.
var as = $.ajax({
url: "https://api.appery.io/rest/1/db/colle...",
type: "GET",
headers: {
"X-Appery-Database-Id": " 548a9dd8XXXXXXX1aa8121f9"
}
}).done(function( data ) {
alert("Done");
});

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Json request

Hi, Ihor thanks for your reply, header or not I am happy that the call to the service is successful! Are you saying that this is not a legitimate method?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Json request

Hi Joe -

Possibly it may be working, but in different order, this needs to be debugged, hard to say at a first glance.

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Json request

Hi Illya, thank you for the reply I will let you know if I experience problems.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Json request

Ok Joe, feel free to let us know.

Return to “Issues”