How to get all items by feature in Azure DevOps - azure-devops

How to get all task items by feature id?
I want to get all the items that belong to a particular feature. Is it possible to do it by using the Rest API?

You can do it with the Work Items - Get Work Item API with the $expand parameter:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?$expand=relations&api-version=5.1
The $expand=relations parameter will return all the items that linked to the work item.

Related

Setting up a pre-deployment gate which validates status of linked work items

I'm trying to setup a pre-deployment gate which validates that all the work items that are linked to the build have a certain status. Eg: Approved for Deployment. I thought I would be able to do this with Query Work Items gate but now I don't think it can be used that way.
The other option that I can think of is to use Invoke Azure Function or Invoke REST API gates that will take the releaseId and then use api calls to find the linked work items and then their statuses.
Is that the right way to do this?
You can use Query Work Items as a workaround since it ensures the number of matching items returned by a work item query is within the configured thresholds.
So you can edit the Queries validating status of linked work items to meet the requirements. The Query Work Items in pre-deployment gate like the following shows:
You can also use REST API to add an Invoke REST API in pre-deployment gate like the following shows:
For how to get Work Item Type States and and validate status of work items, you can call the List REST API as follows:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitemtypes/{type}/states?api-version=6.0-preview.1

Is it possible to retrieve build definition ID related to a work item using Azure DevOps REST API?

The requirement is to fetch all the work items between different releases and create a report. The list of work items can be fetched using below API call.
https://vsrm.dev.azure.com/{organizationName}/{projectName}/_apis/release/releases/{currentReleaseId}/workitems??api-version=6.0&baseReleaseId={baseReleaseId}
Now, for each of this work item, we also need to know the build version when it is delivered. I'm not able to find any entries related to build/release in the work item data fetched using
https://dev.azure.com/{organizationName}/_apis/wit/workItems/{ID}
Is there any relationship between work item tasks and respective build or release definition ID when it was delivered?
Is it possible to retrieve build definition ID related to a work item using Azure DevOps REST API?
The answer is yes.
You could use the REST API Work Items - Get Work Item with $expand to get the commit links:
Get https://dev.azure.com/{org name}/{project name}/_apis/wit/workitems/{id}?$expand=relations&api-version=6.0
Then you would see the commits in relations part of the response body:
Then we could use the REST API Statuses API for Commit. It seems that when starting and ending build, the appropriate status is posted.
So when we call
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/commits/{commitId}/statuses?api-version=6.0
We will get all last builds associated with the Commit and their statuses.

Export of discussion notes from Azure DevOps

Is there a way to export discussion notes from Azure DevOps Work items like Task/Bug etc. Or is there a way in Azure DevOps to get a consolidated web view of discussion? Or can you suggest any extensions that help achieve this?
Checked Azure DevOps for getting the dump through query which did not work
Using the rest api below, you can get the comments records of multiple work items from the response body.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems?ids={ids}&api-version=5.1
But the flaw of this rest api is that it can't display all the comment records, only display the latest comment of this work item.
If you want to get all the comments of a work item, you need to use the rest api below. However, the drawback of this rest api is that it can only return all the comments of a work item, and cannot display the comments records of multiple work items.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{id}/comments?api-version=5.0-preview.2

Get changes associated with a build in Azure Devops using REST API

In Azure Devops under the "Summary" tab associated with a build, there are a list of changes (Git hashes, etc.) associated with the build. I'm trying to figure out how to get these via the rest API.
I found this REST API to get the changes between the two builds.
It works if I have the previous build id in the pipeline, however in the situation I'm interested in, I have the current build id, I need to somehow use the REST API to find the previous id.
Is there a way to do this using the REST API, or a better way to accomplish what I'm trying to do here?
As far as I can see, there's a special REST API call for that. You pass the buildId as a part of the URL and get the collection of changes (Change[]) in response.

How To Use SharePoint 2013 REST API In Order To Remove Contribute Permission On List Item

I want to break the roleinheritance with the SharePoint REST API on a single list item. This can be done using http:///_api/Web/Lists(guid'listid')/Items(itemid)/breakroleinheritance(false).
I am using false as parameter in order not to copy the permissions from the list.
The next goal is to assign reader permission to couple of groups and users (I have the Ids of the users and the groups)
But the next step is more complicated. I must use POST requests in order to update/add permissions and cannot find examples on this.
Any ideas are much appreciated.
Thanks.