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!

How to consume the updated RESTful web service ISBNDB.COM with GET method for in Apex 4.2

PhilMan2Jan 27 2018 — edited Feb 16 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. ?>

This is presenting a few problems in APEX.

Problem #1.  I get an ACL error when I attempt to run the page: ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1130 ORA-24247: network access denied by access control list (ACL)

Previously I had the ACL setup for isbndb.com (without the API prefix).  That ACL worked fine.

I ran the following as SYSDBA to create a new ACL, but I still get the ACL error

PROMPT About to add Privileges to User (Schema) APEX_040200 for the ACL http_api_isbndb_com.xml.;

BEGIN

  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL    (acl         => 'http_api_isbndb_com.xml',

                                        description => 'http_api_isbndb_com.xml',

                                        principal   => 'APEX_040200',

                                        is_grant    => true,

                                        start_date  => systimestamp,

                                        end_date    => null,

                                        privilege   => 'connect');

  DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE (acl         => 'http_api_isbndb_com.xml',

                                        principal   => 'APEX_040200',

                                        is_grant    => true,

                                        start_date  => systimestamp,

                                        end_date    => null,

                                        privilege   => 'resolve');

  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL    (acl         => 'http_api_isbndb_com.xml',

                                        host        => 'api.isbndb.com',

                                        lower_port  => 443,

                                        upper_port  => 443);

COMMIT;

END;

/

PROMPT   Privileges added for principal APEX_040200 with ACL http_api_isbndb_com.xml.;

The Shared Components / Web Service Reference (GET_ISBN_2A2) has the following as a URL  https://api.isbndb.com/

Question #2:  How would I take the PHP code example shown above and create a Web Service Reference for it?

This post has been answered by Pavel_p on Feb 7 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2018
Added on Jan 27 2018
7 comments
1,959 views