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.
- <?php
-
- $url = 'https://api.isbndb.com/book/9780134093413';
- $restKey = 'YOUR_REST_KEY';
-
- $headers = array(
- "Content-Type: application/json",
- "X-API-Key: " . $restKey
- );
-
- $rest = curl_init();
- curl_setopt($rest,CURLOPT_URL,$url);
- curl_setopt($rest,CURLOPT_HTTPHEADER,$headers);
- curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
-
- $response = curl_exec($rest);
-
- echo $response;
- print_r($response);
- curl_close($rest);
-
- ?>
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?