Completed
Implementing Query Parameter Transformation in V2 API
We have built a V2 API to retrieve comments based on the 'postId'. In this scenario, I am trying to achieve two things: first, to fetch the 'postId' from the request API's query parameter and pass it in the body of the backend API, and second, to fetch the 'postId' from the request body and pass it as a query parameter to the backend API. We have successfully achieved the first scenario, but we are now facing issues with the second one.
We are attempting to achieve this by using the 'Transform Query Parameters' transformation. I need help building the EL to fetch the 'postId' from the request body and pass it as a query parameter to the backend API.
0
Comments
Hi Shabnam,
Before using the 'Transform Query Parameters' policy, you can add an 'Assign attributes' policy, with scope set to "request_content", an attribute name of your choice (say "test") and the value set to this Expression language: {#jsonPath(#request.content, '$.postId')}. You can then use this: {#context.attributes['test']} to set the value of the query parameter in 'Transform Query Parameters' policy.
Note that in the info page of the API, you will need to enable - "Emulate v4 engine", since it is not currently supported in v2, but it's in the backlog to support this even without enabling this switch.
Thanks,
Kaustav
Hi Shabnam Shaikh,
I'm following up on this. Was your issue resolved?
Hi Kathyana Queeman,
Thank you for following up. Yes, the issue has been resolved.
Please sign in to leave a comment.