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

POST format for adding a comment with test result using API

Hi,

I am using add_result to update individual test cases using the API.
This is my POST: http://ourserver/testrail/index.php?/api/v2/add_result/3406/1/

What do I need to add to this POST to add a comment at the same time as marking the test as passed?
Please show me the format I need to add. The http://docs.gurock.com/testrail-api2/reference-results#add_result page is not very helpful as it does not give an example.

Thanks

These examples do not help?

{
	"results": [
		{
			"case_id": 1,
			"status_id": 5,
			"comment": "This test failed",
			"defects": "TR-7"

		},
		{
			"case_id": 2,
			"status_id": 1,
			"comment": "This test passed",
			"elapsed": "5m",
			"version": "1.0 RC1"
		},

		{
			"case_id": 1,
			"assignedto_id": 5,
			"comment": "Assigned this test to Joe"
		}


	]
}

Hi, no that doesnt help. I need it to be shown in this format as this is the way I am sending my POST to the API http://ourserver/testrail/index.php?/api/v2/add_result/3406/1/

Hey there,

Using the add_result method you would need to format the body of the API call to include the status ID and comment, and the values for any other result field you want to update. On the document you linked there is an example that also includes additional details for if you are using the separate steps template. The formatting for a basic call would look like this:

{
	"status_id": 5,
	"comment": "This test failed",
	"elapsed": "15s",
	"defects": "TR-7",
	"version": "1.0 RC1 build 3724"
}

I hope that clarifies things! Please let us know if you have any other questions.

Hi,

No that doesn’t help. I am aware I need to format the API call. My question asks how to format. I need the answer to be given in this format http://ourserver/testrail/index.php?/api/v2/add_result/3406/1/

Thanks

I found what I need. The API Call needs to be formatted like this:

http://ourserver/testrail/index.php?/api/v2/add_result/3713&status_id=1&comment=passed

1 Like