How to get team avtar from DevOps api - azure

I have tried to get team details using DevOps API, And I can get it but unable to get team Avtar/image, In response there is only text information, no descriptor available
I am using this way to get it..
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get?view=azure-devops-rest-6.0
Can you please guide me how can I get team Avtar/image ???

How to get team avtar from DevOps api
In the security of Azure Devops, subjectDescriptor is user's SID. It used as identification when operating some security control. This parameter can uniquely identify the same graph subject across both Accounts and Organizations.
To get it, just use the following API:
GET https://vssps.dev.azure.com/{org name}/_apis/graph/users?api-version=5.1-preview.1
From its response body, you can get the descriptor value of corresponding user.
Next, you can pass the corresponding descriptor value as subjectDescriptor into REST API Avatars - Get:
GET https://vssps.dev.azure.com/{organization}/_apis/graph/Subjects/{subjectDescriptor}/avatars?api-version=6.0-preview.1
In addition, the return result of above REST API is content of the image, in order to get the image of the avatar, we need provide the parameter format=png:
Update:
this api for user avtar... i want to get project avtar
To get the project avtar, we need to get the subjectDescriptor of the project. We could use the REST API:
https://dev.azure.com/{organization}/_apis/graph/descriptors/{Teams Id}?api-version=5.0-preview.1
To get the Teams Id, we could use the Teams - Get All Teams:
GET https://dev.azure.com/{organization}/_apis/teams?api-version=5.1-preview.1
Then get the Id of the descriptor for the teams project:
Now, we could get the project avtar:

Use Subject Query from Azure DevOps API Graph
Ref: https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/subject%20query/query?view=azure-devops-rest-6.0
Define the body like this:
{
"query": "Your Group Name",
"subjectKind": [ "Group" ]
}
The descriptor is at the end of each item in a result.
Then use it in belov request to get avatar
https://dev.azure.com/(Organization)/_apis/GraphProfile/MemberAvatars/(descriptor)

Related

Which WhatsApp Business Account ID to use?

Can someone please clarify which is the correct WhatsApp Business Account ID to use to access the WhatsApp cloud API?
I have properly set up my webhook and can receive messages. However when I try to send a message using the WhatsApp Business Account ID (marked as number 1 in the attached image) provided here, I get the following error:
error: {
message:
"Unsupported post request. Object with ID '< my app id>' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
type: "GraphMethodException",
code: 100,
error_subcode: 33,
fbtrace_id: "AQXqjuSJKTWBnyJdUK_W-jj",
},
However when I switch to the second WhatsApp Business Account ID in the curl command (marked as number 2 in the attached image), it works.
What confuses me is that the incoming message has the first WhatsApp Business Account ID (marked number 1 in the attached image) like so:
message: {
object: "whatsapp_business_account",
entry: [
{
id: "xxxxxxxxxxxxxxx", // This matches the first
changes: [
...
],
},
],
};
I am using the current api v14.0. Is there some setting I need to change?
Probably you need to add the user of this acces token to the WABA (Whatsapp Business Account). You can do it by accessing your Business Manager > Whatsapp Accounts menu.
If you don't know which user is this, you can paste the access token value on the Access Token Debug Tool to find out.
PS: it has to be done even for System Users!

Microsoft Graph error processing a storage extension white getting subscription by ID

I am trying to get a subscription by ID from Microsoft Graph REST. If I list the subscriptions using GET /subscriptions, things are working fine and I am able to list all subscriptions. But if I take a subscription id from the list and try to get the details using GET /subscriptions/{id}, I am getting the following error:
{
"error":
{
"code":"ExtensionError",
"message":"There was an error processing a storage extension.",
"innerError":
{
"date":"2021-10-12T06:59:47",
"request-id":"ffa4f181-148d-49ed-8c9d-f551f6ddd6f0",
"client-request-id":"ffa4f181-148d-49ed-8c9d-f551f6ddd6f0"
}
}
}
Any ideas on where I might be going wrong?
PS: I am trying to get an individual subscription because the /subscriptions route does not provide the clientState property which is required for me.
When I route to the same /subscription got the #odata.context link.
I open the same link and search for clientState and got its type but not its value.
Note: the clientState property value is not returned for security purposes.
refer this github
Note : Client State is not set for the List Subscription on purpose by design, because subscription collections could be listed by say some other user (example tenant admin using Subscription.Read.All). It is not desirable to share this Client state information through the Listing API for that user who is not the creator of the subscription.
Reference : https://github.com/microsoftgraph/microsoft-graph-docs/issues/5248

Azure DevOps permissions change for users API?

Is there an API for editing/adding users/user groups to a project's security groups in Azure DevOps? For example, create a new security group under project and add members under it?
Create a group and add members under this new group are separate steps. As of now, we have not provide one api that you can achieve them at once.
(1) To create a new user group under project level:
POST https://vssps.dev.azure.com/{organization}/_apis/graph/groups?scopeDescriptor={scopeDescriptor}&api-version=6.1-preview.1
Request body:
{
"displayName": "{group name}",
"description": "{The description of this group}"
}
Notes:
The only trouble here is getting scopeDescriptor of the project.
Since you are trying to add group under Project level,
scopeDescriptor is a necessary parameter of this api.
a. Please firstly use this api to retrieve the id of the project that you would like to add the group to.
GET https://dev.azure.com/{organization}/_apis/projects?api-version=6.0
b. Then calling this Descriptors - Get api to get the corresponding scopeDescriptor.
GET https://vssps.dev.azure.com/{organization}/_apis/graph/descriptors/{storageKey}?api-version=5.0-preview.1
Please replace storageKey with project Id since we need to
get the scope descriptor for a project. The content of Value
property is what we are looking for:
Please copy the "descriptor" value into a txt file from the response body after you create a new group successfully, it is the important parameter for next steps.
(2) Adding a member into this new group, please refer to this api:
POST https://vssps.dev.azure.com/{organization}/_apis/graph/users?groupDescriptors={xxxxx}&api-version=6.1-preview.1
Request body:
{
"principalName": "{user' account address}"
}
Notes:
Here please input the descriptor value you copied from previous api's response body, as the value of groupDescriptors parameter.
For request body, just input the user's account address is ok.

How to obtain tfid(team foundation id) for azure devops AD group

Could someone provide with the rest api url for finding the tfid for an Azure Devops ad group ?
I am trying to restrict branch permissions for certain AD groups,
"https://dev.azure.com/{organization}/{}/_api/_security/DisplayPermissions?__v=5&tfid={}&permissionSetId={}&permissionSetToken=repoV2%2F{}%2F{}%2Frefs%5Eheads%5E{}%2F".format(projectID, contributorTfid, nameToken, projectID, repoID, permbranchList[k])
only the contributor tfid here is unknown for me.
Using this rest api endpoint, I have to obtain the permissiontoken
later, using permisisontoken using the json
branchPermissionbody = {
"token": "{}".format(permissionToken),
"merge": True,
"accessControlEntries": [
{
"descriptor": "Microsoft.TeamFoundation.Identity;{}".format(descriptorIdentifier),
"deny": 4,
"extendedinfo": {}
}
]
}
I am making a post request to post the restriction on the branches
There are two ways to get the TeamFoundationId.
You can use below REST API to get the groups in your organization.
https://vssps.dev.azure.com/{orgname}/_apis/graph/groups?api-version=5.1-preview.1
Then use Ctrl + F to search the groups in the certain project. The originid is the TeamFoundationId. More details information about this REST API, you can refer to https://learn.microsoft.com/zh-cn/rest/api/azure/devops/graph/groups?view=azure-devops-rest-5.1.
Also you can use F12 to manual catch the TeamFoundationId. Log in to Project settings-> Repositories, then click F12 to open the Network console. Clear sessions then change the group permission. You can get the TeamFoundationId in the Request body or Response body.

Get teams where the user is member, using Bitbucket API

How can I get a JSON object with teams (organizations) where the user is member?
I am searching in documentation and in Bitbucket REST API Console.
Basically I need the correspondent for orgs.getFromUser function from Github API where I pass the username after authenticating.
I think you're looking for this endpoint.
You provide the accountname and authenticate for it, and GET /1.0/groups/:accountname/. It will return a list of objects displayed on the documentation page.
Use the "User Endpoint" for API 1.0
https://confluence.atlassian.com/display/BITBUCKET/user+Endpoint
The call your looking for is: https://bitbucket.org/api/1.0/user/privileges
You need to call this with user authenticated:
curl -u "USER_NAME:USER_PASSWORD" https://bitbucket.org/api/1.0/user/privileges
This will return a list of teams:
{u'teams': {u'team1': u'admin', u'team2': u'admin'}}

Resources