How to handle wrong formatted request urls?
Application Type
Mobile
Service Studio Version
11.10.16 (Build 40208)

Hi guys,


I'm receiving the following POST callback url:

<environment_url>/<app_name>/rest/woodash/auth&scope=read_write

This is how I received the callback but OutSystems does not reads or recognize the "scope" parameter and throw an error 500. If I manually change "¨&" to "?" it works perfectly.

I've also tried to manipulate the request url with "OnRequest" method to change "&" to "?" before the URL goes to the REST API method, but I still got error 500.

The error log of the module says:
A potentially dangerous Request.Path value was detected from the client (&).

The REST config:

Postman test:

Manually changing the URL:


Is there any workaround to this?



The OnRequest.RequestBinary has the same value of OnRequest.RequestText.


But I did a turnaround, since I was defining the callback_url, adding ? char to the end of the URL did the job.

For others that came here in future, also pay attention to the JSON structure of the REST. If the entity expects Integer or Text and the value received is other,you will see a Failed to parse JSON request content. on error logs of your module, which happened to me.

mvp_badge
MVP

Hi Edson,


Does the request, reaches the OnRequest? If so, you can format the incoming the request in that action, replacing for instance the & char with the ? char, to make it a valid URL that can be processed.


To replace it you can use the Replace built-in function to do the replacement :


Kind Regards,
João


Hi @João Marques , thank you for your reply.

Actually that's exactly what I did, but i guess the request never reach OnRequest, because the error persists and the module general errors are happening.

mvp_badge
MVP

Have you debugged to make sure that it reaches / does not reach the OnRequest?

If it doesn't reach the OnRequest, I'm afraid the fix has to be done on the caller said, calling a valid entrypoint.


Kind Regards,
João

I've used LogMessage to see what's coming on OnRequest.RequestText and for my surprise this is the result:

{"key_id":1,"user_id":"user@mail.com","consumer_key":"ck_123456","consumer_secret":"cs_123456","key_permissions":"read_write"}

Yeah, the JSON body and not the URL. OnRequest
Shouldn't it be the URL?

mvp_badge
MVP

Hi Edson,


There is no description in the attributes of the HTTPRequest structure, so it's hard to know. You can however try to see what you have in the HTTPRequest.RequestBinary using BinaryDataToText action from BinaryData and if you see the URL, replace it and convert it back again to Binary using TextToBinaryData:



Kind Regards,
João

The OnRequest.RequestBinary has the same value of OnRequest.RequestText.


But I did a turnaround, since I was defining the callback_url, adding ? char to the end of the URL did the job.

For others that came here in future, also pay attention to the JSON structure of the REST. If the entity expects Integer or Text and the value received is other,you will see a Failed to parse JSON request content. on error logs of your module, which happened to me.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.