Andrew Walker
Posts: 0
Joined: Thu Dec 05, 2013 9:11 am

Using ?WHERE= in URL database call

I have an issue where I am trying to retrieve an object from the database to a website.

codevar s_name = $('#sourceName').text();
var s_id = $('#sourcePasscode').text();
$.ajax({
url: 'https://api.appery.io/rest/1/db/collections/source?where={"source_name":"'+s_name+'", "_id" : "'+s_id+'"}',

beforeSend: function(xhr) {
xhr.setRequestHeader("X-Appery-Database-Id", "529****************d");
},
success: function(data) {
console.log(data);
}
}); /code

There is something incorrect about the call, as I keep getting 400 errors about 'bad request'.

Any ideas on how to fix this ? Thanks

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

Using ?WHERE= in URL database call

Hi Andrew,

Can you post a screenshot of this entire error message?

Andrew Walker
Posts: 0
Joined: Thu Dec 05, 2013 9:11 am

Using ?WHERE= in URL database call

I have tried many ways of doing it, but still get the 'Invalid HTTP 400' error :(

code
$.ajax({
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Appery-Database-Id", "529e2609e4b04c118d013b9d");
xhr.setRequestHeader("Content-Type", "application/json");
},
type: 'GET',
url: 'https://api.appery.io/rest/1/db/collections/source?where={"source_name" : "'+s_name+'"}',
success: function(data) {
console.log(data);
}
});
/code

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

Using ?WHERE= in URL database call

Sorry we still working on this issue without any news.

Andrew Walker
Posts: 0
Joined: Thu Dec 05, 2013 9:11 am

Using ?WHERE= in URL database call

Okay, thank you, thought you had forgotten about me :)

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Using ?WHERE= in URL database call

Hello,

Please try to use simple request first:
pre
$.ajax({
type: "GET",
headers: {
'X-Appery-Database-ID': '5166b6a8e4b055aafd1f2167'
},
url:'https://api.appery.io/rest/1/db/collections/todo',
processData: false,
dataType: "json",
success: function (data) {
console.log("Successfully loaded");
},
error: function (xhr) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
}
});
/pre

if it works then you can add where cause parameter:
http://docs.appery.io/documentation/b...

Also next link should be helpful:
https://getsatisfaction.com/apperyio/...
https://gist.github.com/anonymous/29a...

Andrew Walker
Posts: 0
Joined: Thu Dec 05, 2013 9:11 am

Using ?WHERE= in URL database call

Simple calls work fine, I can bring Collections over and work with them. The problem is when I put the WHERE= .....

This is where I get the error 400 HTTP invalid. So the statement must be wrong, so i am looking for the correct syntax ?

Andrew Walker
Posts: 0
Joined: Thu Dec 05, 2013 9:11 am

Using ?WHERE= in URL database call

Either the syntax is incorrect in the URL, or I am doing something incorrect in the decoding of the JSON.

codeurl: 'https://api.appery.io/rest/1/db/collections/source?where={source_name="'+s_name+'"}'/code

From your documentation, which you first linked on your post, the above should work?

Andrew Walker
Posts: 0
Joined: Thu Dec 05, 2013 9:11 am

Using ?WHERE= in URL database call

Okay, I have changed my URL to this:

codehttps://api.appery.io/rest/1/db/collections/source/where={"source_name" : "testCouncil"}/code

And now I get this error, which means much more to me

Load error: 400 {"code":"DBSG210","description":"Invalid object ID: 'where={\"source_name\"" : \""testCouncil\""}'""}"

Return to “Issues”