Skip to Main Content

ORDS, SODA & JSON in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I want to insert multiple record on cloud table using existing Oracle REST Data Service 2.x which

2930574Aug 10 2015 — edited Aug 10 2015

Need to insert multiple records on cloud table using existing Oracle REST Data Service 2.x  which is on cloud.

Single insertion of record per http POST  is working fine.


Used loop  to iterate and insert for multiple records in  APEX(cloud services)

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

Following query is written under POST method in REST Data Service 2.x on cloud

l_list := json_list(l_clob);

for i in 1..l_list.count LOOP

l_col1 := json_ext.get_string(json(l_list.get(i)),’attributes.NAME’);

l_col2 := json_ext.get_string(json(l_list.get(i)),’attributes.ZIP’);

l_col3 := json_ext.get_string(json(l_list.get(i)),’attributes.ID’); 

INSERT INTO INFODEMO2_DUMMY_TABLE(NAME,ZIP,ID) VALUES (l_col1,l_col2,l_col3);

end loop;

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

Code used to insert the multiple records from external system

HttpClient httpclient = new HttpClient();

PostMethod postMethod= new PostMethod("https://abc.com/apex/sync/dummy/insert/");

postMethod.setRequestHeader("Authorization", "Bearer "+"XXXXXXX");

JSONObject finalJsonObject= new JSONObject();

JSONObject jsonObject= new JSONObject();

JSONArray array= new JSONArray();

jsonObject.put("NAME", "abcd");

jsonObject.put("ZIP", "10");

jsonObject.put("ID", "10");

array.put(jsonObject);

finalJsonObject.put("I_clob", array);

StringRequestEntity requestEntity = new StringRequestEntity(jsonObject.toString(),"application/json","UTF-8");

postMethod.setRequestEntity(requestEntity);

httpclient.executeMethod(postMethod);

Now I am trying to insert only one record using loop..in order to check the correctness!!!

On executing this, I am getting error saying "Bad request"!!!!

Help me in finding out the missing code/logic!!!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2015
Added on Aug 10 2015
0 comments
575 views