oracle-apex

How to generate URL with path parameters instead of query string?


I’m working on Oracle APEX (v 23.1) with Friendly URL mode enabled. I want to generate a page URL where the value of a page item appears in the path, not in the query string.

For example, this is the standard output of apex_page.get_url:

SELECT apex_page.get_url(
    p_application => 500,
    p_page        => 640,
    p_items       => 'P640_ID',
    p_values      => '34491622'
)
FROM dual;

Result:

f?p=500:640:::::P640_ID:34491622

With Friendly URLs enabled, this turns into something like:

https://server/ords/r/app/page?P640_ID=34491622

But what I want is something like:

https://server/ords/r/app/page/34491622

Basically, I want the item value to become part of the path parameters, not the query string. Is there a supported way in Oracle APEX to generate a Friendly URL where page item values automatically become path parameters?


Solution

  • According to the doc, the syntax of a friendly url is

    http://hostname:port/ords/r/path_prefix/app_alias/page_alias?parameters 
    (Such as — p7_customer_id=377&clear=7&session=1247058356345&cs=3MdkfQa9NLmkyHAbwGPg3U-nmA7XIw5sWjU2rMzSvOy_wP1_z7BBI-Gbh2JgvffARgcYJy8id4VtL3d0l1tYm0w)
    

    so based on that, I'd think that it's not possible.

    I'm not sure how your request would work if there is > 1 parameter, or any other setting like request, debug, clear, session, checksum that needs to be passed as part of the url.

    One solution - there might be others - is to create a rest endpoint yourself that attempts to translate an incoming url with format .../page/id to .../page?p1_item=id and passes the original url if it cannot be mapped. I have not tested this, it's just an idea.