Page 1 of 4

Query Appery.io using Oracle APEX

Posted: Tue Nov 18, 2014 10:43 am
by Hawk

Hi,

I need to link Appery DB to Oracle database and use APEX to design an interface such that users can query, update the mobile App DB from Oracle as well as Oracle DB can be updated from the mobile App.

In APEX, I build REST service, in which I use the URI with GET method:

prehttps://api.appery.io/rest/1/db/collections/Outlet_Details//pre

And I added the header:

preX-Appery-Database-Id/pre

When I run the query in the APEX where I insert the Database-Id, APEX shows the table/collection Outlet_Details in JSON format. However, not the entire table is shown due to, I think, the length of CLOB data type.

Now my main problem is I need to query this table/collection called Outlet_Details by a column named: _id. So when I use the following URI:

prehttps://api.appery.io/rest/1/db/collections/Outlet_Details/{_id}/pre

and add another header called _id

It does not return anything no matter what the _id value I insert. So my question, is the method I followed correct? If not, what is missing? and is there any reference to query and update Appery DB from different DB?

Thanks,


Query Appery.io using Oracle APEX

Posted: Tue Nov 18, 2014 11:53 am
by Evgene Karachevtsev

Hello,

"and add another header called _id" - the header _id doesn't need, you should pass _id in the url as you wrote. Please read more here http://devcenter.appery.io/documentat...
I.e. the url will be, for example
prehttps://api.appery.io/rest/1/db/collections/outlet_details/54578046e4b0c9bce12bd075/pre
without any brackets around _id.
If you need to get a list of all the _id from the collection, please use Projection http://devcenter.appery.io/documentat...


Query Appery.io using Oracle APEX

Posted: Wed Nov 19, 2014 3:05 am
by Hawk

Thanks Evgene, by using the url you posted I can get the specific record in APEX. However, I need it to be variable in where-like way. That is, I want to query the collection Outlet_Details by the column userId ( and not _id). So the CURL command is something like:

pre
curl -X GET
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-G --data-urlencode 'where={"userId ": "1234"}'
https://api.appery.io/rest/1/db/collections/outlet_details/
/pre

How can I convert it into URL (adding where condition to the url)?


Query Appery.io using Oracle APEX

Posted: Wed Nov 19, 2014 4:32 am
by Yurii Orishchuk

Hi Hawk,

here is URL example:

pre

{database_url}/collections/outlet_details?where={"userId":"1234"}

/pre

Details: http://prntscr.com/57uwxy/direct

Regards.


Query Appery.io using Oracle APEX

Posted: Wed Nov 19, 2014 4:44 am
by Hawk

Hi Yurri,

I tried this and it returns "HTTP status 400, The request sent by the client was syntactically incorrect".

When I use:
pre{database_url}/collections/outlet_details//pre
It returns the entire collection successfully,
When I use:
pre{database_url}/collections/outlet_details/54578046e4b0c9bce12bd075/pre
It returns the specific recor with _id = 54578046e4b0c9bce12bd075
But when I use :
pre{database_url}/collections/outlet_details?where={"UserId":"1234"}/pre
I get the error above

Thanks for helps


Query Appery.io using Oracle APEX

Posted: Wed Nov 19, 2014 5:19 am
by Yurii Orishchuk

Hawk,

Please show us returned by server error.

Regards.


Query Appery.io using Oracle APEX

Posted: Wed Nov 19, 2014 6:54 am
by Hawk

Hi Yurii,

This is the response without where :

Image

And this when I use where:

Image

Thanks,


Query Appery.io using Oracle APEX

Posted: Wed Nov 19, 2014 12:13 pm
by Evgene Karachevtsev

Hello Hawk,

Please try using urlEncoded value in the url.
i.e. instead of
pre{"UserId":"1234"}/pre
please paste in the url
pre%7B%22UserId%22%3A%221234%22%7D/pre


Query Appery.io using Oracle APEX

Posted: Thu Nov 20, 2014 2:33 am
by Hawk

Thanks Evgene, the urlEncoded value worked for me. But now the question, how to convert each query to urlEncoded? Is there any reference?


Query Appery.io using Oracle APEX

Posted: Thu Nov 20, 2014 4:56 am
by Yurii Orishchuk

Hi Hawk,

Yes you can read about it here:

http://www.w3schools.com/tags/ref_url...

Regards.