omriz | 2022-03-23 18:46:18 UTC | #1
I got the following error when using filter in GET request, works fine in postman.
{ "message": "The request could not be understood by the server due to malformed syntax.", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "4eb06d50-6ee1-43bf-b861-573de15af86f", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [ { "message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 93: https://www.#######.com/demo1/odata/######/tabdem1.ini,3/comp/PHONEBOOK?$filter=PHONENUM eq '0##-######'", "code": "BAD_REQUEST", "status": 400, "messageParams": {}, "details": [], "errors": [] } ] }
anon47876146 | 2022-03-23 20:15:50 UTC | #2
We use the '$' as a special character in our processing to signify escaping using the Velocity Template Language. I don't see in our docs where we call out that you shouldn't use an unescaped '$' in your url so I'll see about getting a note in there for future reference.
You need to change your url to switch the '$' with ${esc.dollar} i.e. https://www.#######.com/demo1/odata/####/tabdem1.ini,3/comp/PHONEBOOK?${esc.dollar}filter=PHONENUM eq '0##-#######' and that should get you past this issue.
You may also need to use some of the Velocity Templating to properly escape the value of the $filter query parameter. Please see my link to our Velocity Template Language help page I linked in the beginning and feel free to reach out here if you need any more help.
omriz | 2022-03-24 07:04:50 UTC | #3
Hi Trey, Thanks for the assistance! I changed it and i'm still getting the same error as below, Do i need to use the Velocity Templating for that to work? This is a GET request so I can't use requestTemplate.
Request URL Template: https://www.#######.com/demo1/odata/#####/tabdem1.ini,3/comp/PHONEBOOK?${esc.dollar}${input.filter}
Execute: { "message": "The request could not be understood by the server due to malformed syntax.", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "f255b356-da14-48fe-b686-88093a4da714", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [ { "message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 93: https://www.#######.com/demo1/odata/####/tabdem1.ini,3/comp/PHONEBOOK?$filter=PHONENUM eq '###-######'", "code": "BAD_REQUEST", "status": 400, "messageParams": {}, "details": [], "errors": [] } ] }
Jerome.Saint-Marc | 2022-03-24 07:53:33 UTC | #4
Hello,
In order to troubleshoot and find what's causing an issue in your Data Action, it would be good if you could post/share details on your Data Action - your Input Contract (as JSON) and your Request Configuration (as JSON).
Regards,
omriz | 2022-03-24 08:07:05 UTC | #5
Hi Jerome, I'm currently just trying to use the Request URL Template without contract fields, just to get a valid response, then I will add it as a contact fields. this is the Request URL Template (I hashed identity values)
{ "requestUrlTemplate": "https://www.##############/demo1/odata/########/tabdem1.ini,3/comp/PHONEBOOK?${esc.dollar}filter=PHONENUM eq '###########'", "requestType": "GET", "headers": { "Authorization": "Basic ################" }, "requestTemplate": "${input.rawRequest}" }
Response: { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }
Jerome.Saint-Marc | 2022-03-24 10:11:14 UTC | #6
$ is a keyword for the Data Actions. That's why you need to replace it with a Velocity macro - ${esc.dollar}
What is also necessary is to escape certain characters in the url properly. When you have " " (space) in a url, it will be replaced with %20 When you have ' (single quote), it will be replaced with %27.
So your request template should look like this:
"requestUrlTemplate": "https://www.##############/demo1/odata/########/tabdem1.ini,3/comp/PHONEBOOK?${esc.dollar}filter=PHONENUM%20eq%20%27###########%27"
Let's assume you define an input parameter in your input contract ("phone" of type string). You would use it the following way in your requestTemplate
"requestUrlTemplate": "https://www.##############/demo1/odata/########/tabdem1.ini,3/comp/PHONEBOOK?${esc.dollar}filter=PHONENUM%20eq%20%27${input.phone}%27"
You can check the answer I gave on this other post.
Regards,
omriz | 2022-03-24 19:16:14 UTC | #7
Finally! :slight_smile: Appreciate the help Jerome, Thanks!
system | 2022-04-24 19:16:26 UTC | #8
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 14016