Outsystems encoding issue in RESTAPI Content-Type: application/x-www-form-urlencoded

Outsystems encoding issue in RESTAPI Content-Type: application/x-www-form-urlencoded

  

I am consuming a REST API, using the POST method. The API gives me a Bad Request, 400 error. In the Trace I can see: "The authorization code provided is not valid" . 

When I am posting the exact same request data and authorization code with Postman, I am getting no errors and the expected result in the result body.


The attached file shows the request headers and body for both. The only difference I noticed (and this may be the cause of the error???) is that Outsystems encodes the special characters with lowercase instead of uppercase used by Postman and as they should be. For example:

Outsystems encoding of "/" : %2f

Postman encoding of "/" : %2F

Could this be the reason that my authorization code as posted by Outsystems is not recognized by the oAuth API???

Solution

Hi Denis

This is actually a know issue with Consume REST. The problem isn't in the encoding of "/", it's the "+" character. On the OutSystems request you have "...oCyV+uRGqU..." while on Postman you get "...oCyV%2BuRGqU..."

To workaround this, you should replace "+" by "%2B" on the OnBeforeRequest callback 

Solution

Ok João, thank you very much.  I confirmed that this is indeed the issue and everything works fine now.  Are there any other characters that do not get encoded or is it just the "+"? I assume this is scheduled to be fixed?

Hi Denis

The major problem is with the "+" character (which in itself is encoding for a space). It will be fixed in a later version, but there's no due date yet