Hello Apigeeks
<AssignMessage async="false" continueOnError="false" enabled="true" name="Payload"> <DisplayName>Payload</DisplayName> <Set> <Payload contentType="application/json"> {"bookid":"{request.queryparam.bookid}"} </Payload> </Set> <Remove> <QueryParams> <QueryParam name="bookid"/> </QueryParams> </Remove> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
Above, I set json payload from the queryparam and removed them from queryparam. Next, I print proxy request with javascript policy.
var req_request_uri = context.getVariable('proxy.url'); print(req_request_uri);
Result is not as expected. Supposingly, it only returns without the queryparam since I already removed them.
In my experience, the AssignMessage works as intended. A few points of feedback though.
Here is my working example.
pxzxz1-remove-query-param-apiproxy.zip
I think the reason you are seeing different result sis possibly because of the attachment point you used for the AssignMessage policy. Consult my example to see what works.
Hello @dino-at-google
Thank you for the demo. Unfortunately, it does not work. I do not understand
For this proxy, it is a no target endpoint. I accept queryparam such that it is ?bookid=10. I will use assign message policy to take the queryparam, set it as a request payload i.e. {"books": {"bookid": "10"}}
After that, remove the queryparam from the proxy path and execute service callout to the target endpoint with a request payload.
Unfortunately, it does not work.
I'm really sorry about that. Also, I have no idea how to help you further because I cannot diagnose a problem with a report like "it does not work".
If you do not understand why policies are attached at specific points, please consult the documentation regarding preflow, postflow, and other attachment points.
I hope after you read a bit more, you'll be able to use my example as a starting point to accomplish what you want. Good luck!
@Patricia,
Actually there is a misunderstanding. The assign-message policy is removing the query parameter from the request. If you see the request flow further the query param is not available in the flow.
when you are printing the proxy.url this will be showing because the proxy url variable is set at the beginning when the request reaches the message processor and that is the same in the flow. The assign message policy is not doing any change in proxy url. The policy is removing the queryparam from the request flow directly. This is working in my case.