Skip to Main Content

SQL & PL/SQL

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!

POST data using UTL_HTTP

Ryansun-OracleJul 9 2012 — edited Jul 9 2012
Hi There,

First of all, I am using the UTL_HTTP package for the first time. Basically, we have to POST JSON data to a URL. The format of the data is

{"definition":"Part","item":"Part1","value":"123"}
{"definition":"Part","item":"Part2","value":"789"}
...
{"definition":"Part","item":"Partn","value":"345"}

Now using the Curl command we can run the comand
$ curl -X POST http://xyz.com/test -H 'Content-Type: application/json' -d '{"items":[
{"definition":"Part","item":"Part1","value":"123"}
{"definition":"Part","item":"Part2","value":"789"}
...
{"definition":"Part","item":"Partn","value":"345"}
The same needs to be implemented in PL/SQL, I found this link

http://technology.amis.nl/2012/01/19/publishing-to-cometd-bayeux-channel-from-inside-the-oracle-database-plsql-based-push-to-cometd-web-client/


I was getting the error

Error report:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-29261: bad argument
ORA-06512: at line 61
29273. 00000 - "HTTP request failed"
*Cause: The UTL_HTTP package failed to execute the HTTP request.
*Action: Use get_detailed_sqlerrm to check the detailed error message.
Fix the error and retry the HTTP request.



This was after I tried changing the POST procedure to a anonymoust block and tried to run it since we do not have create rights on the DB. Before I post the change, just wanted to check if anyone has any suggestions on impementing this in PL/SQL, basically, we just need to send 2 columns data in JSON format to a URL on a daily basis.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2012
Added on Jul 9 2012
1 comment
1,541 views