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

Update_case API can be used for updating the custom fields of test run e.g. "Automation Status"


#1

I am unable to update the custom fields using the update_case API after getting the same from
JSONArray casefields = (JSONArray)client.sendGet("get_case_fields…

Is it possible and supported in test rail?

Also if possible check my code, what can be the issue:

Map<String, String> data = new HashMap<>();
data.put(“custom_automationprogress”, “Automated”);
client.sendPost(“update_case/xxx”,data);

Result:
TestRail API returned HTTP 400(“Invalid or incomplete JSON string in API request.”)


#2

Hello Pooja,

Thanks for your post! Custom fields would be supported with the update_case API method, as this would allow the same POST fields as the add_case method (which includes custom fields). You can learn more about the supported POST fields on our website (just expand the Request fields section):

http://docs.gurock.com/testrail-api2/reference-cases#add_case

The error you’re receiving just indicates that your request isn’t formatted properly (as the request isn’t in proper JSON format). We wouldn’t be able to troubleshoot your specific script as part of our support, but you can also view request examples and proper formatting via the link I provided above. You can also learn more about using TestRail’s API together with Python in general (including some example POST requests) on our website as well:

http://docs.gurock.com/testrail-api2/bindings-python

Hope this helps!

Regards,
Marco


#3

Thanks for the reply,also there is one more question…does testrail support bulk edit using some API like update_cases?Is there any document available for the same about input it expect?


#4

Hi,
Please let me know the API request JSON for custom field update through API for filed"Automation Status” on testrail test cases

Thanks
Chandrashekhar


#5

Hi Chandrashekha,

To update a field in a test case using the API, you would include the field name you need to update and the value to update the field to. If you have a custom field, you would use the field’s system name (prefixed with ‘custom_’ as the field identifier).

As an example, you could have JSON as follows:

{
	..
	"custom_preconds": "These are the preconditions for a test case"
	..
}

If you are unsure of the system name for any field, you can use the ‘get_case_fields’ method (described here), which will provide you with the system names of all your custom fields in TestRail.

Hope this helps!
Jon


#6

Hi,
Thanks for the reply, am new to testrail API’s,
I tried with API update_case/:case_ID
{
“custom_automation_status”: “Completed”
}
am not getting error and 200 OK getting back with response and but
field “custom_automation_status” is not updated and not seen in the suit/case display but other fields like “type_id”, “priority_id” and “refs” am able to see the changes

{
“id”: 1851825,
“title”: “Login with valid user name and password”,
“section_id”: 218327,
“template_id”: 1,
“type_id”: 2,
“priority_id”: 1,
“milestone_id”: null,
“refs”: null,
“created_by”: 369,
“created_on”: 1537773910,
“updated_by”: 497,
“updated_on”: 1543330752,
“estimate”: “5m”,
“estimate_forecast”: “5m”,
“suite_id”: 14531,
“custom_automation_candidate”: null,
“custom_automation_prime”: null,
“custom_automation_status”: null,
“custom_automation_forecast”: null,
“custom_automation_effort”: null,
“custom_recommendation_status”: null,
“custom_captive_details”: null,
“custom_specific_release_introduced”: null,
“custom_rqa_sub_team”: null,
“custom_customer_tag”: null,
“custom_preconds”: null,
“custom_steps_seperated”: [
{
“content”: “1. Launch \n2. Login with correct user name and password”,
“expected”: “1. After successful login, it should show the default page for that user.\n2. user name should be displayed in right top corner.”
}
]
}

It would be appreciable if anybody can help me to resolve this

Thanks


#7

Hi Chandrashekhar,

The field type for “custom_automation_status” will affect how the field is handled. For example if this field is a checkbox for a value “Completed” you would update_case with

{

“custom_automation_status”: “true”

}

You can find out more about using each field type from the following add_case >> expand Request fields.

http://docs.gurock.com/testrail-api2/reference-cases#add_case