Search code examples
encodingmulemule-studioanypoint-studio

How do I prevent mule from encoding the query-param?


In a HTTP request, I am adding a token as a query-param. It seems that mule is encoding the value. - If I add the parameter, mule will encode it in the way it is wrong. - If I add already encoded parameter, mule will double encode it and therefore won't be usable anymore.

So the question is: Is there a way or a workaround to prevent mule from encoding the URL query-param?

Example of the parameter: {AES}ZEoksxIg484magPtWwNUUQ==;iT0kI2HsqGkh%2Bdc2baW2B4dNR2vouKkWQsDTdbMP8us=


Solution

  • My colleague found a workaround for this, so I'm sharing it here.

    Apparently, you can set a variable before the HTTP request and add the manually encoded value. Let's call it ourTokenVariable In my example above that would be %7BAES%7DZEoksxIg484magPtWwNUUQ%3D%3D%3BiT0kI2HsqGkh%252Bdc2baW2B4dNR2vouKkWQsDTdbMP8us%3D

    After that, you can use this newly created variable directly in the url path. For example: /example/someapi?someToken=[#flowvars.ourTokenVariable]

    This way you don't need to use uri-param or query-param anymore (where mule is double encoding the value). The value will be taken 'as is'.