0
votes

I am using this api to fetch bug from devops org work item

$api = "https://{0}.almsearch.visualstudio.com/{1}/_apis/search/workItemQueryResults?api-version=5.1-preview" -f $OrganizationName, $ProjectName

$body = '{"searchText":"Title: my xyz title here","skipResults":0,"takeResults":2,"sortOptions":[],"summarizedHitCountsNeeded":true,"searchFilters":{"Projects":["myprojectname"],"Work Item Types":["Bug"],"States":["Active","New"]},"filters":[],"includeSuggestions":false}' | ConvertFrom-Json

Invoke-RestMethod -Uri $uri -Method POST -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $userlogintoken)} -Body $body

I don't have bug id.

I don't want to use title and tag or description, repro steps in searchtext to query bug from DevOps.

Are there any fields where I can put some unique value while creating bug then while searching I can use that value to search for a particular bug?

(i am creating bug using my script. before creating I need to query in DevOps whether the same bug is not already present then only create new)

1
Not get your response for several days, would you please share your latest information about this issue? If you have any concern, feel free to share it here. - Hugh Lin
You can have a try creating a custom field for bug work item type. Then you can use this custom field to search for the bug. - Levi Lu-MSFT

1 Answers

0
votes

I need to query in DevOps whether the same bug is not already present then only create new

For this issue, I am afraid there should be no other fields except titile, tag, discussion, repro steps that can be used as query conditions to search for a particular bug. In these special fields, we can add specific descriptions as query conditions, but this cannot be achieved in other given fields.

As workaround, you can create a custom field for the bug item in the Process of the organization settings. About how to add a custom field to a work item type (Inheritance process), you can refer to this official document for details. After adding the custom field, you need to put value for the bug items' custom fields that already present before.