Search code examples
oracle-databaseoracle-apex

How to get host name and request headers for ORDS RESTful Services?


I have Oracle 18c database with Apex 19.2.

I created an ORDS RESTful Service to receive some POST requests from another application.

I need to get some detailed informations about the request sent to my RESTful service.

So I'm using the implicit parameters documented here:

https://docs.oracle.com/en/database/oracle/oracle-rest-data-services/18.3/aelig/implicit-parameters.html#GUID-E7716042-B012-4E44-9F4C-F8D3A1EDE01C

For example : :body, :content_type...

declare
        RequestBodyReceived blob;
begin
        RequestBodyReceived := :body ;
        insert into SomeTable (RequestBody) values (RequestBodyReceived);
        :status_code := 201;
end;

enter image description here

This is nice but I can't find other informations about the request. Mainly the sender host, the headers, etc.

How can I get sender Host and Request headers?


Solution

  • Use the following code as an endpoint source to check all available CGI variables.

    begin
        for i in 1..nvl(owa.num_cgi_vars, 0) loop
            htp.p(owa.cgi_var_name(i) || ': ' || owa.cgi_var_val(i));
        end loop;
    end;
    

    I found it some time ago on the Internet, but I don't remember where was it.