title: Azure API Management: json-to-xml policy with consider-accept-header
body: <p>I'm trying to transform a json response to xml if the request contains Accept=application/xml. Otherwise, the json response should be returned.</p>
  
  <p>Here's my policy:</p>
  
  <pre><code>&lt;policies&gt;
    &lt;inbound&gt;&lt;base /&gt;&lt;/inbound&gt;
    &lt;backend&gt;&lt;base /&gt;&lt;/backend&gt;
    &lt;outbound&gt;
      &lt;base /&gt;
      &lt;json-to-xml apply="content-type-json" consider-accept-header="true" /&gt;
    &lt;/outbound&gt;
    &lt;on-error&gt;&lt;base /&gt;&lt;/on-error&gt;
  &lt;/policies&gt;
  </code></pre>
  
  <p>When I test this without an Accept header, all is well (200 OK and json is properly returned). </p>
  
  <p>Adding the accept header, however, I get a 406 Not acceptable. </p>
  
  <p>The trace (after adding the header Ocp-Apim-Trace:true), redacted is available at <a href="https://gist.github.com/jhgbrt/9df92cb0a140804ea01c" rel="nofollow">https://gist.github.com/jhgbrt/9df92cb0a140804ea01c</a>. In that trace, you will see the following:</p>
  
  <ul>
  <li>in the 'inbound' part confirm the request header 'Accept' with value 'application/xml' is present. The <code>request-executor</code> block contains a message saying "Request is being forwarded to the backend service."</li>
  <li>in the 'outbound' block you already see the 406 not acceptable and the Accept header removed, after which the json-to-xml block fails because of this.</li>
  </ul>
  
  <p>What am I missing?</p>