Can I put SQL odata filter into request body of a POST data action

Hi, I have some trouble with my odata endpoint queries in data actions.
I have an Azure SQL DB which I want to query from GC via a Data Action.
I have created an odata endpoint which I would like to use to query my SQL DB table for calling number.
The odata query url is looking like the following:

https://ODataServerEndpoint/DBTable?$filter=contains(callingNumber,'123456')

But if I create a Data Action with this URL $filter is not a correct syntax for the request url template.
So I tried to find the correct syntax for $ sign but couldn't find a solution.
The other option I would like to use is to put the odata query filter into request body of a POST request.
Can anybody help me to do this? How is the correct syntax of the request body and which Headers do I have to set?
Thanks in advance!
Tobias

1 Like

Hi Tobias,

To get a $ into a velocity template you can use $esc.dollar
See the string escaping examples here: Velocity macros for data actions - Genesys Cloud Resource Center

--Jason

Hi Jason,

how exactly should my request url for the data action look like?

https://odataendpoint/sqltable?$esc.dollar'filter'=callingNumber%20eq%20'${input.ani}' is not working.

The query url should look like the following

https://odataendpoint/sqltable?$filter=callingNumber%20eq%20'${input.ani}'

Cheers,

Tobias

Hello,

For URL (escaping special characters): space should be escaped into %20, and ' (single quote) should be escaped into %27.
You can use the escape velocity macros.
But as the characters to escape are not in your input parameter (i.e. input.ani), you could set them directly as desired in the requestUrlTemplate (Data Action Request Configuration).

Example 1:
URL you want to query:
https://ODataServerEndpoint/DBTable?$filter=contains(callingNumber,'123456')
This url would be escaped as:
https://ODataServerEndpoint/DBTable?$filter=contains(callingNumber,%27123456%27)
Your requestUrlTemplate can be set to:
https://ODataServerEndpoint/DBTable?${esc.dollar}filter=contains(callingNumber,%27${input.ani}%27)

Example 2:
URL you want to query:
https://odataserverendpoint/DBTable?$filter=callingNumber eq '123456'
This url would be escaped as:
https://odataserverendpoint/DBTable?$filter=callingNumber%20eq%20%27123456%27
Your requestUrlTemplate can be set to:
https://ODataServerEndpoint/DBTable?${esc.dollar}filter=callingNumber%20eq%20%27${input.ani}%27

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.