Search code examples
wso2wso2-api-managerpolicy

WSO2 API Manager 4.1.0 - JSON2XML policy not working


There is Hello World API is onboarded into WSO2 APIm 4.1.0 GA release. I added JSONtoXML policy from policy List to Response flow by follows steps provided in WSO2 APIM Doc and deployed in DEV portal by clicking save and deploy option

JsonToXML.j2 - Policy file Content:

<property name="messageType" value="application/xml" scope="axis2"/>

Policy in publisher:

Policy in publisher

When I Try out this API in DEV portal or via postman, it is still giving response as JSON format, not in XML

WSO2 DEV Portal - TRY IT OUT:

WSO2 DEV Portal

POSTMAN:

postman

As suggested below - API Gateway Sequence Hit:

api gateway sequence test

CURL Request like below:

curl -k "https://127.0.0.1:9443/api/am/gateway/v2/sequence?apiName=HelloWorld&version=1.0.0" -H "Authorization: Bearer eyJ4NXQiOiJOMkpqTWpOaU0xxx" 

Note: valid token is passed in above curl Request, same token used when calling apim url which gives backend response

Did I miss anything or if not why this policy enablement is not working in WSO2 APIM? Please clarify on the same


Solution

  • I just followed the same flow to the Pizzashack API in the APIM 4.1.0 GA pack. It worked as expected without any issue. enter image description here

    Can you confirm that you have created a new revision after this policy addition and deployed it in the gateway?

    If you have done that as well, shall we use the gateway Rest API and check the sequences for the HelloAPI. There should be a new sequence with the above policy attached.

    Edit:

    If the sequence call does not contain a response, that means the policy has not been deployed properly. To apply the policy properly, create a new revision and deploy that revision in the gateway.