Our Logic Apps suddenly started to receive empty payloads from API Management after our APIM instance got the July, 2022 release. We opened a ticket with Microsoft Support and found out the following:
When API Management forwards a message to the backend it does so when reaching the backend section of the policies. When this section starts there is a short period of time where APIM reads the request body and if APIM is not done reading the body during this period it will (due to performance improvements) start sending chunked messages to the backend service. This is for most backend service a standard and good way, but since Logic App trigger does not support chunking this becomes a problem for us. Since the Logic App will start a run by the incoming request but since it dosen’t support chunking the run will have a empty incoming payload.
This can be detected when the receiving service starts to get requests with the header Transfer-Encoding: chunked.
Example output of the trigger action on Logic Apps, with the Transfer-Encoding header and no body property.
In order to solve this we need to make sure the entire request body is read in APi Management before the request is started to be sent to the backend. This is fortunally easily achieved with adding a read of the incoming body in the inbound policy section. Here is a simple example of how this could be achived, setting the body of the request for the backend to the full read incoming request from the caller:
We where also recommended by Microsoft Support to explicitly declare the forward request in the backend section and set the buffer for the request body to true.
The full policy will then look like this: (removed all the other stuffs for simplicity)
When this fix was added the issues we had in Logic Apps where solved.
We encountered this on large messages that where sent to us. But Microsoft Support informed us that our problems already started around 1000 kilobytes. So from now on we will add this fix to all our APIs that potentially will receive a large payload. Hopefully Logic Apps http trigger will support chunked messages in the future.