Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Query Appery.io using Oracle APEX

Thanks Yurii. I have another question with with PUT method.

First, I used the following code with (GET) method successfully to copy data from collection "Outlet_Details" where the column "Oracle_Flag" = Y to Oracle DB.

pre ....
-- service's input parameters

-- preparing Request...
l_http_request := UTL_HTTP.begin_request('https://api.appery.io/rest/1/db/collections/Outlet_Details?where=%7B%22Oracle_Flag%22%3A%22Y%22%7D'
, 'GET'
, 'HTTP/1.1');

-- ...set header's attributes
UTL_HTTP.set_header(l_http_request, 'X-Appery-Database-Id', '53f2dac5e4b02cca64021dbe');
--UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_param_list));

-- ...set input parameters
-- UTL_HTTP.write_text(l_http_request, l_param_list);

-- get Response and obtain received value
l_http_response := UTL_HTTP.get_response(l_http_request);

UTL_HTTP.read_text(l_http_response, l_response_text);

DBMS_OUTPUT.put_line(l_response_text);
l_list := json_list(l_response_text);
.../pre

No I tried to use the similar way with (PUT) method in order to update one column in the collection "Outlet_Details" where Oracle_Flag = Y, and update it to "N"

pre ...
-- service's input parameters
l_param_list := 'Oracle_Flag=N';

-- preparing Request...
l_http_request := UTL_HTTP.begin_request ('https://api.appery.io/rest/1/db/collections/Outlet_Details?where=%7B%22Oracle_Flag%22%3A%22Y%22%7D'
, 'PUT'
, 'HTTP/1.1');

-- ...set header's attributes
UTL_HTTP.set_header(l_http_request, 'X-Appery-Database-Id', '53f2dac5e4b02cca64021dbe');
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'application/json');

-- ...set input parameters
UTL_HTTP.write_text(l_http_request, l_param_list);

-- get Response and obtain received value
l_http_response := UTL_HTTP.get_response(l_http_request);

UTL_HTTP.read_text(l_http_response, l_response_text);

DBMS_OUTPUT.put_line(l_response_text);

-- finalizing
UTL_HTTP.end_response(l_http_response);
.../pre

I get the error: "code":"DBSP007","description":"Serialization error"

Are the way I'm using Appery collection parameteres correct?

Thanks,

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

Query Appery.io using Oracle APEX

1) Request Content Type should be JSON instead urlEncoded
2) Format for updating collection row slightly differs from getting it from DB
curl -X PUT \
-H "X-Appery-Database-Id: DB_ID" \
[-H "X-Appery-Session-Token: "] \
-H "Content-Type: application/json" \
-d '{"":""}' \
{database_url}/COLLECTION_NAME/ < object_id

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Query Appery.io using Oracle APEX

Hi Egor,

Do you I should replace

preUTL_HTTP&#46;set_header(l_http_request, 'Content-Type', 'application/json');/pre

with

preUTL_HTTP&#46;set_header(l_http_request, 'Content-Type', JSON);/pre

What else do I need to change?

Thanks,

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query Appery.io using Oracle APEX

Hi Hawk,

Nope, you have correct content type.

You should pass all request parameters (where and operations) in payload request part as JSON. So there is no ability to pass parameters through the URL(like in GET request).

See details here: http://prntscr.com/5au3m5/direct

Unforturnalty i don't know how to do it with this "UTL_HTTP" please read documentation.

Regards.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query Appery.io using Oracle APEX

Hi Hawk,

I guess you have some wrong symbols in your base64.. You need to escape them to use in JSON string.

More details here: http://stackoverflow.com/questions/30...

Did you try to pass empty value in base64 image?(just to test it)

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Query Appery.io using Oracle APEX

Correct, I found there were newlines which after I removed it works fine.

Thanks Yurii. Happy new year!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query Appery.io using Oracle APEX

Hi Hawk,

Thanks for this update.

Glad it works now.

Regards.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Query Appery.io using Oracle APEX

Hi Hawk,

Here is CURL to update certain user:

pre

curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "X-Appery-Session-Token: c6771e2f-44ae-42ea-9946-5fa320578233"
-d "{"email":"stacy@somemail&#46;com"}"
https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users/54539efee4b05c4ac3b9737f

/pre

More details here: http://devcenter.appery.io/documentat...

So i can see following inconsistent in your code:

  1. Wrong url. Should be:

    pre

    &#47;&#47;Where "54539efee4b05c4ac3b9737f" is user id that you want to update&#46;
    https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users/54539efee4b05c4ac3b9737f

    /pre

  2. You can not use "where" clause for this collection. (this collection does not support it).

  3. Instead of "set" parameter - you should use appropriate parameter that you want to update.

    Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Query Appery.io using Oracle APEX

Hi Yurii,

Thanks for the clarification. I have the following questions:

1) In point 3, you mentioned that I should use appropriate parameter in stead of "set". What is the appropriate parameter here. May you give example?

2) Since I cannot use "where", and I must use this format:
prehttps:&#47;&#47;api&#46;appery&#46;io/rest/1/db/users/54539efee4b05c4ac3b9737f/pre

Does that mean I can only update by the _id ?? What If I want to update the record based on some other field (e.g. username)? Is that possible? If yes, How?

3) Do I need to provide session-token? How to retrieve the value of the session-token?

-------------------------------------------------------------------

Aside from this, I need to use 'DELETE' method to delete all records in normal collection (not users). However, my request works only when I provide _id value:

preurl VARCHAR2(4000) := 'https:&#47;&#47;api&#46;appery&#46;io/rest/1/db/collections/Test_Member_Points_Details/54b6437fe4b04a26676ce472/pre

Is there anyway to delete without providing _id (e.g. using wildcard)? Or the only way to use 'GET' first to collect all_id's and then use 'DELETE' ?

Many thanks,

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Query Appery.io using Oracle APEX

Hi, Will I get any update on this here or should I post new thread?

Return to “Issues”