Search code examples
oracle-apexoracle-rest-data-services

Why isn't my Oracle Rest-Enabled SQL Reference being recognised?


Been fighting with this one for days. Hopefully, I'm being thick and there's a semicolon missing from somewhere.

I've been trying to setup a reference to my REST-enabled SQL (RESS) on my local box, and Apex refuses to acknowledge it.

I'm using the article at https://docs.oracle.com/database/apex-18.1/HTMDB/rest-enabled-sql-creating.htm#HTMDB-GUID-0906921E-AF79-49D4-B909-1C090F805D9D, which seems quite straightforward.

Before you ask:

  • Yes, I've enabled the schema for REST
  • Yes, I've enabled RESS in the defaults.xml file enter image description here
  • Yes, I've tested the RESS away from APEX, using a curl command like curl -i -X POST --user testuser1:testuser1 --data-binary "select sysdate from dual" -H "Content-Type: application/sql" -k http://localhost:8080/ords/hr2/_/sql, and it works.

Then in APEX->Shared Components->Data Sources->REST Enabled SQL, I've setup this reference: RESS reference

and it uses these credentials:

credendtials

However, when I initially created the reference, and when I test it, I get the following message:

enter image description here

What on earth am I doing wrong? Using Oracle APEX 21.2.0 and ORDS Version 21.4.1.r0250904


Solution

  • the screen shots look good. I would now check whether the database can reach the ORDS endpoint with APEX_WEB_SERVICE, as follows (you can use either SQL*Plus or SQL Workshop for this):

    declare
        l_result clob;
    begin
        apex_web_service.set_request_headers(
            p_name_01   => 'Content-Type', 
            p_value_01  => 'application/sql' );
    
        l_result := apex_web_service.make_rest_request(
                        p_url         => 'http://localhost:8080/ords/hr2/_/sql',
                        p_http_method => 'POST',
                        p_username    => 'TESTUSER1',
                        p_password    => 'testuser1',
                        p_body        => 'select sysdate from dual' );
    
        dbms_output.put_line( l_result );
    end;
    

    Possible errors are ...

    • the PL/SQL Network ACL was not set up for the APEX_XXXXXX user
    • the database has a proxy server defined, which is not valid