I am consuming a ASP.Net WEB API written in c# hosted in IIS6. When making a POST to the API it returns HTTP status 413. The API (not WCF) returns response as long as the content in the body is around 32+KB. If the size is like 40 KB then it errors out.
Below is the code snippet on the consumer side
string apiUrl = "https://a.com/api/emails/send";
using (WebClient client = new WebClient())
{
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("Accept", "application/json");
try
{
var jsonResponce = client.UploadString(apiUrl, jsonRequest);
var sendEmailResponce = JsonConvert.DeserializeObject<SendEmailResponce>(jsonResponce);
var emailMessageId = sendEmailResponce.EmailMessageId;
Console.WriteLine("email sent.");
}
catch (WebException exp)
{
var error = exp.ToString();
Console.WriteLine(error);
}
catch (Exception exp)
{
var error = exp.Message;
}
}
I am using IIS6 . Is there any setting in IIS / Code changes on the client might help me to get around this issue?
try this,