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

Getting 400 Bad request for index.php?/api/v2/add_result_for_case/:run_id/:case_id


#1

Hi, I am trying to make a POST call to update testrail run with test results for a test case, but I get 400 Bad request for it.

Request:
http://testrail*****/index.php?/api/v2/add_result_for_case/81111/3476235
Authorization:Basic XXXXXXXXXXXXXXXXXXXXX
Content-Type:application/json
Body: {“status_id”: 1, “comment”: “success”}

Response:
400 Bad Request
Body:
Bad Request

I do get proper response when I invoke Get TestRun call using same credentials.
Request:
http://testrail******/index.php?/api/v2/get_tests/81111
Authorization:Basic XXXXXXXXXXXXXXXXXXXXX
Content-Type:application/json

Response:
200 OK
Body:
[
{
“id”: 14223115,
“case_id”: 3476235,
“status_id”: 3,
“assignedto_id”: 1347,
“run_id”: 81111,

}
]

Can you help me to know what I am missing here?


#2

Found the answer, request payload was missing a mandatory custom field.

The API error message ‘Bad request’ was very generic and was tough to identify. It seems, this is default message for various errors. It would be helpful, if we could get more descriptive error messages.