title: AZURE API Management - Object reference not set to an instance of an object
body: <p><strong>Azure API Management is with a response &quot;System.NullReferenceException: Object reference not set to an instance of an object.&quot;</strong></p>
  <p>MyFunction.Run(HttpRequest req, ILogger log) in MyFunction.cs:line 61</p>
  <p>method signature</p>
  <p>public async Task Run(
  [HttpTrigger(AuthorizationLevel.Anonymous, &quot;get&quot;, Route = null)] HttpRequest req,
  ILogger log)</p>
  <p>Sorry everybody, I newer in Azure APIM!</p>
  <p>When I send JSON below in request body to c# azure function API, everything works as well!!</p>
  <pre><code>{
      &quot;Id&quot;:40,
      &quot;status&quot;:&quot;Doing&quot;,
      &quot;startedDateTime&quot;:&quot;2019-10-17T17:50:44.1314885Z&quot;
  }
  </code></pre>
  <p>But when I sending it thru the Azure API Management to serverless azure function API Microservice,
  I'm getting the error message &quot;Object reference not set to an instance of an object.&quot;</p>
  <p>My Azure function has only APIM Key into headers and no more things; I just created APIM consumption  for use as an endpoint,
  I have only CORS policy and trying to use  for a test, but I got the same problem with </p>
  <pre><code>&lt;policies&gt;
      &lt;inbound&gt;
          &lt;base /&gt;
          &lt;choose&gt;
              &lt;when condition=&quot;@(context.Request.Body != null)&quot;&gt;
                  &lt;set-body template=&quot;liquid&quot;&gt;
                      &lt;value&gt;@(context.Request.Body.As&lt;JObject&gt;(preserveContent: true).Value&lt;string&gt;())&lt;/value&gt;
                  &lt;/set-body&gt;
              &lt;/when&gt;
          &lt;/choose&gt;
      &lt;/inbound&gt;
      &lt;backend&gt;
          &lt;base /&gt;
      &lt;/backend&gt;
      &lt;outbound&gt;
          &lt;base /&gt;
      &lt;/outbound&gt;
      &lt;on-error&gt;
          &lt;base /&gt;
      &lt;/on-error&gt;
  &lt;/policies&gt;
  </code></pre>
  <p>Someone can help me?
  What would be the same solution?</p>