Page 1 of 1

How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Wed Jul 03, 2013 8:53 pm
by Christopher Herold

Looking for a method to create a REST service to query my appery database with a format that would mimic SELECT * FROM [DB] WHERE x and .


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Wed Jul 03, 2013 9:03 pm
by Kateryna Grynko

Hi Christopher,

As a result return:
codewhere={ $and: [ { "studentId": 20 }, { "other_field": 10} ] }/code


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Wed Jul 03, 2013 9:09 pm
by Christopher Herold

Hi Katya,

What URL do I use under Settings?

I am trying

/[DB_ID]]https://api.appery.io/rest/1/db/colle...

but it does not work.


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Wed Jul 03, 2013 9:33 pm
by Alena Prykhodko

Database is identified with header X-Appery-Database-Id and it shows which database you are accessing to work.

Backend services- Databases - Collections.

Look previous comment and the following reference http://docs.appery.io/documentation/b... to complete request 'where'.


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Wed Jul 03, 2013 11:03 pm
by Christopher Herold

I have been looking over the documentation and it not clear to me what I should enter in the GUI to create my customized RESTService.

I need to know what goes in the Settings, Request and Response tabs for the RESTService that I am creating in order to submit a simple query with a "where" clause.

(1) Does the database ID go under the Request tab?
(2) What do I do with this example code that I can get from from the Database for GET? Do I take the URL only and put that in the Settings? What is the object ID?
curl -X GET \
-H "X-Appery-Database-Id: 51ccdbe3e4b0901..." \
[-H "X-Appery-Session-Token: "] \
https://api.appery.io/rest/1/db/colle...

Right now I have the URL in the Settings Tab set as:
https://api.appery.io/rest/1/db/colle...

I have set a parameter in the Request tab of X-Appery-Database-Id and entered my database ID as the default value.

I have set as a parameter in the Response tab:
where={ $and: [ { "user_name": cdherold }, { "profile_text": testing} ] }

But it appears that I am still not correctly specifying the database ID correctly.

{
"status":"400 Bad Request",
"url":"https://api.appery.io/rest/1/db/colle...",
"response":{
"code":"DBSQ002",
"description":"database id not specified"
}
}

Please advise. Thank you!


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Wed Jul 03, 2013 11:13 pm
by maxkatz

This tutorial shows exactly how to setup a 'where' query: http://docs.appery.io/tutorials/build...


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Mon Jun 02, 2014 2:39 am
by Tooba Atif

Hi Max,
Can you please send the link to that tutorial the above is not working!


How to Create a REST Service for a DB Query with multiple WHEREs?

Posted: Mon Jun 02, 2014 3:16 am
by Illya Stepanov