The user is hitting the api and the response will get but we need to handel the responce fields based on the user reqirement in the wso2 APIM.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="Final-using-script">
<property name="clientUsername" scope="default" expression="$ctx:api.ut.userId"/>
<log level="custom">
<property name="userId" expression="$ctx:clientUsername"/>
</log>
<script language="js">
<![CDATA[
var payload = mc.getPayloadJSON();
var log = mc.getServiceLog();
log.info(payload);
var user = mc.getProperty('clientUsername');
if (user === 'abc@carbon.super') {
delete payload.MobileNo;
delete payload.EmailID;
delete payload.SurveyorName;
} else if (user === 'xyz@carbon.super') {
delete payload.InsClaimNo;
delete payload.Acknowledgment;
delete payload.RejectionMsg;
}
mc.setPayloadJSON(payload);
]]>
</script>
</sequence>
But i'm getting all the fields from the response it's not getting removed.
I have tried with the payloadFactory mediator also.
The user should get with the minimum fields.