Home » SQL & PL/SQL » SQL & PL/SQL » Consuming Rest API from PL/SQL using UTL_HTTP - body not recognized (11.2.0.4.0)
Consuming Rest API from PL/SQL using UTL_HTTP - body not recognized [message #686414] Thu, 08 September 2022 06:40 Go to next message
skfaheem024
Messages: 5
Registered: September 2022
Junior Member
Hi,

I am new to this forum and consuming Rest API's using PL/SQL. I am trying to consume a rest service from pl/sql, but the server is not able to identify the request. The same request works from postman.. so no problem in the service, something with my pl/sql code i think..

I am trying the free api provided by rapidapi. (link, code and script are attached as i am not able to use links in my first post)
Re: Consuming Rest API from PL/SQL using UTL_HTTP - body not recognized [message #686415 is a reply to message #686414] Thu, 08 September 2022 06:42 Go to previous messageGo to next message
skfaheem024
Messages: 5
Registered: September 2022
Junior Member
The response from server is {"error":{"code":1003,"message":"Parameter q is missing."}}
Re: Consuming Rest API from PL/SQL using UTL_HTTP - body not recognized [message #686416 is a reply to message #686414] Thu, 08 September 2022 09:07 Go to previous messageGo to next message
John Watson
Messages: 8796
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum.
Please read the OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.



Can you work up to the problem slowly, one bit at a time? Rather than trying to write the whole procedure in one shot? For example, first the basic connectivity. This works for me:
orclz>
orclz> select utl_http.request('https://weatherapi-com.p.rapidapi.com/ip.json',wallet_path=>'file:c:\tmp\wallet') from dual;

UTL_HTTP.REQUEST('HTTPS://WEATHERAPI-COM.P.RAPIDAPI.COM/IP.JSON',WALLET_PATH=>'FILE:C:\TMP\WALLET')
-----------------------------------------------------------------------------------------------------------------------------------------
{"message":"Invalid API key. Go to https:\/\/docs.rapidapi.com\/docs\/keys for more info."}

orclz>
Re: Consuming Rest API from PL/SQL using UTL_HTTP - body not recognized [message #686420 is a reply to message #686416] Sat, 10 September 2022 01:11 Go to previous message
skfaheem024
Messages: 5
Registered: September 2022
Junior Member
Hi John,

Thank you for your response. Yes this works when i was trying it out and did not pass the apikey as the header.. But once the header was provided, the error was of the parameter q.
Previous Topic: Where is the session timeout value for the duration of running an sql query/procedure
Next Topic: Running Balance
Goto Forum:
  


Current Time: Wed Feb 08 20:05:36 CST 2023