Skip to Main Content

APEX

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!

Consuming a RESTful Web Service with JSON

PhilMan2Feb 1 2018 — edited Feb 2 2018

Hello,

I'm using Oracle 11.g, Apex 4.2 and ORDS 3.0.8 on a Windows 10 Server.

ISBNDB.COM recently changed its API. For years I consumed it as an XML payload. It worked fine. But now it appears that XML support was recently removed and I must consume the data with an output format of JSON. Additionally, it seems the base URL changed from ISBNDB.COM to API.ISBNDB.COM

The code below was copied from the ISBN site https://isbndb.com/apidocs#/ . I replaced the text "YOUR_REST_KEY" with my actual key. The text "9780134093413" is the ISBN number of a book to be looked up. This would typically be a variable that would be passed in. It produces expected results.

  1. <?php

  2. $url = 'https://api.isbndb.com/book/9780134093413';

  3. $restKey = 'YOUR_REST_KEY';

  4. $headers = array(

  5. "Content-Type: application/json",  
    
  6. "X-API-Key: " . $restKey  
    
  7. );

  8. $rest = curl_init();

  9. curl_setopt($rest,CURLOPT_URL,$url);

  10. curl_setopt($rest,CURLOPT_HTTPHEADER,$headers);

  11. curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);

  12. $response = curl_exec($rest);

  13. echo $response;

  14. print_r($response);

  15. curl_close($rest);

  16. ?>

The above PHP code works well. However, this is presenting a few problems in APEX 4.2.

I'm having a problem testing out a Shared Components / Web Services Reference. Here's a copy of the screens

pastedImage_0.png

pastedImage_1.png

pastedImage_2.png

The X-API-Key field contains my private API key that I received from ISBNDB.COM

The URL field = https://api.isbndb.com/book/9780134093413

When I click the TEST button I get the response:

ORA-29273: HTTP request failed

ORA-06512: at "SYS.UTL_HTTP", line 1130

ORA-12545: Connect failed because target host or object does not exist

How do I setup a Web Service Reference for REST / JSON so that produces results like the ones produced with the sample PHP code?

Thanks for looking at this.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2018
Added on Feb 1 2018
2 comments
722 views