[Background]
I would like to append additional Query Params to all incoming requests going into my Mulesoft REST-API app. The idea is to develop a Mulesoft Custom Policy, with HTTP Policy Transform Extension
to achieve it.
[Problem statement]
Let’s say the incoming requests url is //localhost:8081/hellomule?id=1
, how do I use HTTP Policy Transform Extension
to append additional query params. For example, let’s append a query param of ?name=jackson
.
-
Original URL:
//localhost:8081/hellomule?id=1
-
Expected:
//localhost:8081/hellomule?id=1&name=jackson
-
As observed above, the expectation is that query params name=jackson will be appended onto the original url
[template.xml]
In this file, I have written an implementation to hardcode name:jackson as query params.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="....."
xmlns:xsi="....."
xmlns:http-policy="....."
xmlns:http-transform="....."
xsi:schemaLocation=".....">
<http-policy:proxy name="{{{policyId}}}-custom-policy">
<http-policy:source>
<!-- This is not working -->
<http-transform:set-requester-request>
<http-transform:query-params>#[{('name': 'jackson')}]</http-transform:query-params>
</http-transform:set-requester-request>
<http-policy:execute-next />
</http-policy:source>
</http-policy:proxy>
</mule>
I have used <http-transform:set-requester-request>
and <http-transform:query-params>
to inject the query params of {('name': 'jackson')}
, however it does not seems to be working. The url remains the same //localhost:8081/hellomule?id=1
, without &name=jackson
.
I am guessing I am missing things, or I have misunderstood the use of the HTTP Policy Transform Extension. I am hopeful to get some advise from the community please, thank you.