Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

API error "Maximum POST size was exceeded"


#1

I am trying to use the API and I am receiving an error: “Maximum POST size was exceeded”.

my post looks like this:

/index.php?/miniapi/add_result/36908&key=mykey

{“status_id”:1,“comment”:“Automated Test Passed.”}

Headers:

Accept: application/json
Content-Length: 66
Content-Type: application/x-www-form-urlencoded; charset=utf-8
etc…

I’m using FireFox 21.0

I’ve tried changing the Content-Type “application/json” to “application/x-www-form-urlencoded” but no change.

Any ideas of what the issue is?


#2

Hello David,

Thanks for your posting. Could you let me know which tool do you use to access the API? You mentioned that you are using Firefox. Are you using an add-on/plugin to submit the POST request?

Regards,
Tobias


#3

I am actually posting from a C# library… HttpClient.

My tests run from nunit, run in Firefox, and then nunit posts to the API via HttpClient (post).

here is how C# is POSTing to the API

	[code]    var uri = string.Format("http://{0}/index.php?/miniapi/{1}/{2}&key={3}", TestRailIpAddress, Apimethodname, testRailResult.test_id, ApiKey);
        var httpClient = new HttpClient();
        httpClient.DefaultRequestHeaders.Add("Accept", "application/json");

        
        var apiResponse = httpClient.PostAsync(uri, new StringContent(serializedObject, Encoding.UTF8, "application/x-www-form-urlencoded")).Result;
        if (!apiResponse.IsSuccessStatusCode)
        {
            // LOG EXCEPTION TO NUNIT
            throw new Exception(apiResponse.Content.ToString());
        }[/code]

Additionally, I can see the POST in fiddler and it looks correct (JSON, headers, url).


#4

Problem has been solved!

I notice in fiddler that I was POSTing a JSON object, not a URL encoded object.

now my POST looks like this:

the API now works!


#5

Thanks for the update, David, and great to hear that it works now. The error message you got back was a bit misleading and indicated that there was indeed something wrong with the POST format but good to hear that were you able to resolve this in the meantime.

Regards,
Tobias