Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

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

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 .

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Christopher,

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

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

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

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.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

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

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'.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

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

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!

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

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

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

Tooba Atif
Posts: 0
Joined: Fri Apr 04, 2014 3:07 am

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

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

Return to “Issues”