question

ClemensTan-8488 avatar image
0 Votes"
ClemensTan-8488 asked ClemensTan-8488 commented

Azure Api Management throws System.Exception: Content length mismatch

Hello,

an Azure Function is responding to an HTTP PUT request an 400 error with a body which contains some error text. When calling the Azure Function HTTP directly from the Azure function, the HTTP trigger responses correctly. If called through the ApiManagement, the API Management discards the body and throws
System.Exception: Content length mismatch

I can't figure out, what is going wrong here. Same with 422 response code. With response code 200, the body is sent correclty.

azure-api-management
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ClemensTan-8488 I will suggest you to review the traces and verify whether the exact failure is either from Inbound, Backend or Outbound section and verify whether there could be any policy causing the issue.

0 Votes 0 ·

We found a "bug". It seems that there is a 64kb limit in the response body, whenever a return code is not 200. I guess it is a bug. I could not find any limitations in the documentation.
The Azure Function returns the full body, but the APIManagement ha a problem, with a payload above 64kb

We are using the consumption plan of the API Management. With the Basic Tier, the problem does not occure.

0 Votes 0 ·

@ClemensTan-8488 Thanks for your respose. I have tried to reproduce the issue at my end but couldn't observe the error : System.Exception: Content length mismatch but I do see 500 error when the return code is not 200 and the patyload is more than 64KB. I will reach out to my team on the confirmaton if this is expected behaviour.

0 Votes 0 ·
Show more comments

0 Answers