title: Azure API Management Service Set body Policy - modify JSON response to return certain fields
body: <p>Based on </p>
  
  <p><a href="https://docs.microsoft.com/en-us/azure/api-management/api-management-transformation-policies#SetBody" rel="nofollow noreferrer">Azure API Management Service "Set body" Policy</a></p>
  
  <p>We can modify the response of an API service. For Eg., instead of returning below : </p>
  
  <pre><code>{ 
    "company" : "Azure",
    "service" : "API Management"
  }
  </code></pre>
  
  <p>We would only like to return : </p>
  
  <pre><code>{ "company" : "Azure" }
  </code></pre>
  
  <p>I am not sure how to accomplish this as I have no idea what kind of programming language / syntax they are using in their documentation as shown below : </p>
  
  <pre><code>&lt;set-body&gt;  
  @{   
      string inBody = context.Request.Body.As&lt;string&gt;(preserveContent: true);   
      if (inBody[0] =='c') {   
          inBody[0] = 'm';   
      }   
      return inBody;   
  }  
  &lt;/set-body&gt;  
  </code></pre>