Search code examples
oracle-apex

Apex 22.1 REST Data Source - 400: Bad request for ajax_dispatch_request


Added a REST Data Source and below is its Test Result from Apex Dev Env itself. Requests from Thunder Client and Swagger are OK as well. But, there is 400 error on the application.

Any help please!

REST Data Source
    Name:           Directors 2
    REST Data Source Type:  Oracle REST Data Services
    Remote Server:      localhost
    Base URL:       http://localhost:5164/
    URL Path Prefix:    /Directors

LOV in Shared Component
    Name:           LOV_DIRECTORS
    Data Source:        REST Data Source
    REST Data Source:   Directors 2

Page item P3_NEW 
    Type:           Popup LOV
    List of Values
        Type:       Shared Component
        List of Values: LOV_DIRECTORS   

enter image description here

enter image description here

Debug Messages are

APEX Version=22.1.0 SID=402 USER=APEX_PUBLIC_USER ECID=d9Ts0zI_6CGd1rFN70j8JQ PROXY_USER=ORDS_PUBLIC_USER INSTANCE=1 CGI: PATH_INFO = /wwv_flow.ajax?p_context=pibasworld%2Frest-data-source%2F8967875288500 POST http://localhost:8080/ords REMOTE_USER=APEX_PUBLIC_USER APEX_LISTENER_VERSION=22.2.0.r1721758 REFERER=http://localhost:8080/ Error: Ajax call returned server error ORA-20999: REST Data Source returned an HTTP error: HTTP 400: Bad request for ajax_dispatch_request.

  • is_internal_error: true
  • is_common_runtime_error: false
  • apex_error_code: APEX.AJAX_SERVER_ERROR
  • ora_sqlcode: -20999
  • ora_sqlerrm: ORA-20999: REST Data Source returned an HTTP error: HTTP 400: Bad request ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3644 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3201 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2232 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2002 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 1918 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 608 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 1913 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2198 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2249 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC", line 830 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC", line 1124 ORA-06512: at "APEX_220100.WWV_FLOW_LOV", line 1741 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3132 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3629 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 7309 ORA-06512: at "APEX_220100.WWV_FLOW_PLUGIN~
  • error_backtrace: ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3644 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3201 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2232 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2002 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 1918 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 608 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 1913 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2198 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC_WEB_SRC", line 2249 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC", line 830 ORA-06512: at "APEX_220100.WWV_FLOW_EXEC", line 1124 ORA-06512: at "APEX_220100.WWV_FLOW_LOV", line 1741 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3132 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 3629 ORA-06512: at "APEX_220100.WWV_FLOW_NATIVE_ITEM", line 7309 ORA-06512: at "APEX_220100.WWV_FLOW_PLUGIN", line 2455 ORA-06512: at "APEX_220100.WWV_FLOW_PLUGIN", line 4133 ORA-06~
  • component: APEX_APPLICATION_PAGE_ITEMS P3_NEW (2346920829881307)

Solution

  • I've seen that you created the REST Data Source as of the "ORDS" type. Is your REST API really an ORDS REST API, or is it something else? If you're really using an ORDS REST Module here, change the REST Data Source type to "SImple HTTP". If that does not help, a LEVEL9 debug of the error page would be helpful - that will show all the details of the HTTP request which APEX made, and you should be able to quickly see where things go wrong.

    The reason why this was not flagged by the "Test" operation is that "Test" does not append any parameters to the URL. However, when you use the REST API in a report, APEX appends "offset" and "limit" parameters to the URL for ORDS REST Sources, as APEX "knows" that ORDS will then return only the exactly requested rows. Your REST API however, just coughed on these and rejected with HTTP-400.