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

"update_case" overwrites the custom fields instead of appending or updating it


#1

Hi,

the current info of the test case is as below:

URL: /index.php?/api/v2/update_case/92571122

{
      "id": 92571122,
      "title": "Add passenger details",
      "custom_testtype": [80]
   }

The below details need to be updated for a test case.

URL: /index.php?/api/v2/update_case/92571122

{
	"custom_testtype": [100]
}

custom_testtype is a multiple selection type which can have values like 80,90,100 which are configured.

Instead of updating the custom_testtype field, it is overwriting it.

Expected Output is:

{
      "id": 92571122,
      "title": "Add passenger details",
      "custom_testtype": [80,100]
   }

Can you please let me know how to update an multiple selection values without overwriting it?


#2

Hi Sanjay,

Thanks for your post! The update_case method would just set the value of the field as specified in the API request, so in this case as you’re just setting 100 as the value of the field, this would be set for the field in the test case and override any previous value. TestRail wouldn’t be able to know whether you want to replace the existing value, or add onto/append to the existing value. We would just recommend using the get_case method first to review the values of any field, and if you need to append anything you can use the previous response to build your update_case request (and you can create a script for this to handle this programmatically if you do this often). Hope this helps!

Regards,
Marco


#3

This answer is not really useful. If you’re running multiple tests that want to add themselves to the same test run, you’re going to run into a race condition where it’s possible for two or more get_case calls to receive the same values, add their test case and the latest one to do so will overwrite the one just before it.