Nagashree Balasundaram Currently, it is not possible to remove namespaces with XML-to-Json
policy (no attributes exists xml-to-json-policy). But you can write custom policy expression to parse JObject within set-body
and remove namespaces or other elements based on your need. Here is the sample policy snippet:
<xml-to-json kind="direct" apply="always" consider-accept-header="false" />
<set-body>@{
var request = context.Request.Body.As<JObject>();
var obj = (JObject)request.SelectToken("RESPONSE_GROUP");
obj.Property("@xmlns$xsi").Remove();
obj.Property("@xmlns$xsd").Remove();
obj.Property("@xmlns").Remove();
return request.ToString();
}
</set-body>
Note, this is just for reference, and you may have to loop through the elements and validate before attempting to remove them. Refer JSON.NET documentation for more info on how to parse/remove. Feel free to submit your feedback or idea directly to our product team via https://aka.ms/apimwish. I hope this helps with your questions and let me know if you have any.
If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.