1

Can anyone please share the details how to create a test case in azure devops using rest api, preferably in python code. I couldn't find a direct API in azure devops but they shared an API for work item. But I don't have an idea how the body should be while creating a test case. Please suggest.

https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/create?view=azure-devops-rest-6.1

1
  • Regarding the body of the work item while creating test case is not mentioned anywhere. I have seen this example code for get projects but it would be great if anyone share a sample code to create a work item as test case with the exact body format. Thanks Commented Oct 3, 2020 at 9:22

1 Answer 1

3

How to create test case in azure devops using rest api in python

The test case is also a work item. That is the reason why they shared an API for work item for you.

When you create a workitem with TestCase type:

enter image description here

Then we could find it display on the test case tab:

enter image description here

So, we could use the REST API Create a work item to create a workitem with Testcase type to create the test case:

PATCH https://{instance}/DefaultCollection/{project}/_apis/wit/workitems/${workItemTypeName}?api-version={version}

On the other hand, we could check the REST API about the Test cases, there are Get a test case, Delete a test case but no create the test case API directly.

To create a workitem in python, you could refer this official Azure DevOps Python API doc.

It contains Python APIs for interacting with and managing Azure DevOps. These APIs power the Azure DevOps Extension for Azure CLI. To learn more about the Azure DevOps Extension for Azure CLI, visit the Microsoft/azure-devops-cli-extension repo.

Here is some example code for creating work item in python.

You could check this thread for some more details.

Sign up to request clarification or add additional context in comments.

1 Comment

I have seen many post which mentions the same that I can create a test case by using work item. But I didnt find any post where it actually mentions what should be the data input to the rest api while creating a test case using create work item api. Can somebody please help me as Im getting error by giving the data shared in microsoft doc for azure rest api.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.