Kannan Selvaraj Thanks for posting your question in Microsoft Q&A. I assume you are looking to remove requestedDate
from head
property in JSON and you can try the following code snippet (similar discussion):
Code snippet:
<set-body>@{
var jsonResponse = context.Response.Body.As<JObject>(preserveContent: true);
var headObject = (JObject)jsonResponse["head"];
headObject.Properties()
.Where(x => x.Name.Contains("requestedDate"))
.ToList()
.ForEach(x => headObject.Remove(x.Name));
return jsonResponse.ToString();
}</set-body>
Output:
If you are looking to remove requestedDate
from all the elements, you would need to loop through all properties of JSON response instead of just head
property. Checkout JSON.NET (API management uses Newtonsoft.Json; .NET Framework types allowed) and samples to navigate through complex path. I hope this helps and let me know if any questions.
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.