We have an Azure API which accepts a List<string>
. It works fine locally, and it works fine when called by a web page. However, when we call it on the server from Postman, it only works when the string (for purposes of our discussion and testing we’re only sending one) is less than 102362 characters, but gives a 403 when it’s greater than 102362 characters. It doesn’t even make it inside the method.
Same problem in JMeter.
This is the signature of the method:
[HttpPost]
[Route("MergeBase64ToPDF")]
public IResult MergeBase64ToPDF([FromBody] MergeBase64ToPDFRequest MergeBase64Request)
{
//doesn't make it here
2
Answers
By default, Azure App Services have a maximum request size limit. check that Kestrel in ASP.NET is configured to accept larger payloads.
Configure the request size limit.
program.cs:
Here I created a simple script to generate a base64-encoded string exceeding the size threshold:
large_payload.json
file.After this I have deployed my application to app service and tested using postman
Made a
POST
request to the API.There are 3 places where this error could be thrown – the web application server (Kestrel), Azure Web Application Firewall, Azure APIM. As the web application that connects to the API is able to send this request and only the Postman requests are failing, I suspect this is due to Azure Web Application Firewall. Refer this article to modify the limits in WAF.
For controlling content length in APIM please refer this thread