Adding an AAD group to Azure DevOps using the rest api - azure-devops

I am attempting to do a put on
https://team.vssps.visualstudio.com/_apis/Graph/Memberships/{aadgp.GroupDescriptor}/vssgp.{GroupDescriptor}
I can come up with the ADO group starting with vssgp. but I have been unable to come up with the AAD descriptor.
Calling AAD graph with
https://graph.microsoft.com/v1.0/groups?$filter=displayName eq 'groupName'
doesnt appear to provide me anything that looks like that and calling
https://team.visualstudio.com/_apis/IdentityPicker/Identities?api-version=6.0-preview
with body
{
"query": "groupName",
"identityTypes": ["group"],
"operationScopes": ["ims", "source"]
}
doesnt give me anything that starts with aadgp.
I am running out of ideas and was hoping one of you may have done this already. I am unable to get all of the groups that have access to the org or team project as it will likely be a new group being added.
tia

You have to make a bunch of calls.
Get Azure graph to get Guid of group
GET https://graph.microsoft.com/v1.0/groups?$filter=displayName eq ‘GroupName’
Get projects to determine id of project I need
GET https://dev.azure.com/{organization}/_apis/projects?api-version=6.0
Post to group entitlements to add the new group in
POST https://vsaex.dev.azure.com/{organization}/_apis/groupentitlements?api-version=6.0-preview.1
Get all groups from the org to get the aadgp value
GET https://vssps.dev.azure.com/{organization}/_apis/graph/groups?api-version=6.1-preview.1
Put on graph membership to add the group
PUT https://vssps.dev.azure.com/{organization}/_apis/graph/memberships/{subjectDescriptor}/{containerDescriptor}?api-version=6.0-preview.1
Delete on group entitlements to eliminate unneeded group entitlement
DELETE https://vsaex.dev.azure.com/{organization}/_apis/groupentitlements/{groupId}?api-version=6.0-preview.1

Related

Extract work items to an excel with more fields added to it

I am extracting the list of bugs from Azure Devops using Query. I was able to extract the bugs but it was extracted only with ID, Description, work item type and assigned to fields alone. I wanted to extract the list of bugs with some more fields like closed by, created by, raised by. I have explored custom setting but I could not able to get the desired result. Let me know if this is achievable in Azure Devops please.
In Azure DevOps portal, seems you could not export them to csv with these values.
You could export them and get the work item ids, then use the REST API - Work Items - Get Work Item in a loop, the API will return the values you want.
Please refer to the sample response here - https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/get-work-item?view=azure-devops-rest-6.0#get-work-item

Get Area ID from Azure DevOps

I need to get Area ID of the work item in Azure DevOps for creating custom rules in the process. Currently, I can only find Area Path of work item but for creating rules we need Area ID.
Additionally, you can add "Area ID" into the work item query columns:
You can use Classification Nodes - Get Root Nodes Rest API with $depth property to get all the area paths.
In the response you will get the Id for the Areas:

Getting user/users details based on user name/alias as parameter in azure devops

I've a tool(web application) which creates work-items in azure devops. (skipping the unnecessary details), just like how we assign any user a particular work-item from the Assigned To dropdown in azure devops, I too have a dropdown which when user enters any name/alias, a list of users starts showing based on the input.
The api which I was using in the backend was
https://abcorganization.vsaex.visualstudio.com/_apis/UserEntitlements?top=10&filter=name+eq+%27Tejas
Here filter=name+eq+%27Tejas in the query parameter helps to query the api and used to give set of users whose name starts with Tejas. It can be email alias too.
But for some reason, that doesn't work anymore. My guess, they've deprecated that API version
So in my search to find the alternative/answer, I came across the following documentation:
(https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/users/get?view=azure-devops-rest-5.1) in which the API given is: https://vssps.dev.azure.com/abcorganization/_apis/graph/users/{userDescriptor}?api-version=5.1-preview.1
Here the userDescriptor is some sort of unique key of AAD related to a particular user. (which I certainly can't use to fulfill my purpose).
The other thing which I've tried is the below query parameters but it still didn't worked out
https://vssps.dev.azure.com/abcorganization/_apis/graph/users?subjectTypes={subjectTypes}&continuationToken={continuationToken}&api-version=5.1-preview.1
So is there anyway/api which can fullfil my purpose or is it that I'm using this new API in a wrong way or something?
Any help would be much appreciated
I believe it should be $filter in the query. You are also missing the closing quote.
(See docs for more details)
https://abcorganization.vsaex.visualstudio.com/_apis/UserEntitlements?top=10&$filter=name+eq+'Tejas'
Use this. I tested it and worked for me:
https://vsaex.dev.azure.com/{organization}/_apis/userentitlements?$filter=name+eq+%27{name}%27&api-version=6.0-preview.3
Replace {organization} and {name} as needed

Possibly a bug. PowerShell get-team searchs $filter=resourceProvisioningOptions/Any(x:x eq 'Team')

MS Graph API for Teams can create a team without resourceProvisioningOptions property set.
But, when get all teams with PowerShell 0.9.5(Microsoft.TeamsCmdlets.PowerShell.Custom.dll), it calls HTTP Get with "https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team')"
So, it cannot returns all teams.
According to your description, I assume you want to list the teams by using the Power Shell.
I have tied this, and it works. First, I tried the following API GET https://graph.microsoft.com/beta/groups?$filter=resourceProvisioningOptions/Any(x:x eq 'Team') on the MS Graph Explorer. And it works. Then, I tried this API on the PowerShell, it works too.
According to this document,
If the group was created less than 15 minutes ago, it's possible for the Create team call to fail with a 404 error code due to replication delays.
So it maybe the reason about you could not get all the teams

How to get Yammer messages of particular group?

I used
https://www.yammer.com/api/v1/search.json
but am getting all the messages of yammer.
But I am in need of getting messages only for 1 group.
There is no group paramter in above API to sort.
I am in need of search message/topic of particular group.
Help is appreciated !
This is the API you would need to call:
https://www.yammer.com/api/v1/messages/in_group/{{group_id}}.json
I don't see this specifically supported in the Yammer Developer Docs so make sure you understand that it might be removed or changed in the future:
https://developer.yammer.com/v1.0/docs/rest-api-rate-limits
You could also use the Data Export Api and that generates a csv of messages that you could filter on group ids.
It's not possible to search by group using the API. What you can do though is to filter the JSON response by the group ID. For example, if your group ID is 12346, fetch the response then apply a custom filter in your code to get all messages that has "messages.group_id:12346".