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

Python: testrail.APIError: Unable to add result to "custom_step_results"


I want to update the results for individual steps under"custom_step_results". I have written a python code below:

if value['custom_parentsteps'] != None:
    print("Test ID: %s" %(value['id']))
    print("Case ID: %s"%(value['case_id']))
    data={"custom_step_results": [{"status_id": 2}]}


Here value[‘id’] is Test ID.

I am getting following error. Could someone please take a look.

testrail.APIError: TestRail API returned HTTP 400 ("One of Status ID, Assigned To or Comment is required")


Anyone please reply to my query please ?


Hi there,

Thank you for your post. TestRail is mentioning that the ‘status_id’ or other required fields are missing, and this likely means that you have not correctly submitted the POST arguments with your request. Based on the example you referenced, it does not look like you have included all of these.


Hi, Thanks for the reply.
Do you mean I need to include all these fields:

"custom_step_results": [
			"content": "Step 1",
			"expected": "Expected Result 1",
			"actual": "Actual Result 1",
			"status_id": 1

Mentioned in ??
Basically I want to add test results to individual steps value['custom_parentsteps'] , not overall test result. Could you please let me know.



Thank you for the follow up. You should be including all of those variables in your call.


Hello, Thanks for the reply. I tried with all variables, but still it is not working. Could you give me an example of setting results for individual steps using python APIs?

Also according to , ‘actual result’ is an optional field, but you suggested to include “all” variables.

Here is my whole code:


from testrail import *
from pprint import pprint
import json

client = APIClient('')
client.user = 'xxxx'
client.password = 'xxxxx'

#Each user has its id. This function returns respective user id
def get_user_id():
    #print user_id['id']
    return user_id['id']

#Get the test cases for the test run . You need to specify Test run id.


for value in tests:
    if value['custom_parentsteps'] != None:
        print("Test ID: %s" %(value['id']))
        print("Case ID: %s"%(value['case_id']))
        data={"custom_step_results": [{"status_id": 2,'content': 'Build and install any sample app on the device.', 'expected': 'App installs successfully.'}]}


Sill I am getting following error:

Traceback (most recent call last):
  File "", line 38, in <module>
  File "/Users/nzunjarwad/my_scripts/", line 51, in send_post
    return self.__send_request('POST', uri, data)
  File "/Users/nzunjarwad/my_scripts/", line 79, in __send_request
    (e.code, error))
testrail.APIError: TestRail API returned HTTP 400 ("One of Status ID, Assigned To or Comment is required")



Thanks for your reply! We wouldn’t be able to provide any code/language-specific assistance as part of our support, but we’re happy to help with any general questions you have regarding the TestRail API methods and their syntax. From the error provided, it looks as though you’re not sending over one of the required fields (Status ID, Assigned To, or Comment). Please note that at least one of these fields also needs to be added for the overall test in addition to the fields/statuses that are added to the steps. You can see an example JSON request below:

	"comment": "Comment here",
	"custom_step_results": [
			"actual": "Actual Result 1",
			"status_id": 1
			"content": "Step 2",
			"expected": "Expected Result 2",
			"actual": "Actual Result 2",
			"status_id": 2

Hope this helps!



Hello, Sorry i was not able to explain but my suggestion is to attend a free demo class by 12+ years experience on Python they are giving some free demo class so you can attend Here! Python