I would like to create an Azure DevOps notification subscription via REST call. The recipient email address needs to be passed in and not default to my own email address. The ultimate goal is to programmatically create subscriptions so that certain non-ADO users can be automatically alerted about the resolution of work items that are relevant to them.
Thanks!
custom DevOps notification subscription via REST call
To create the notification subscription, you could use this REST API Subscriptions - Create:
POST https://{service}.dev.azure.com/{organization}/_apis/notification/subscriptions?api-version=6.0
Sample Request body:
{
"description": "A new work item enters our area path",
"filter": {
"eventType": "ms.vss-work.workitem-changed-event",
"criteria": {
"clauses": [],
"groups": [],
"maxGroupLevel": 0
},
"type": "Expression"
},
"subscriber": {
"id": "xxxxxxd71-c2fef2ad085f"
},
"channel": {
"type": "EmailHtml",
"address": "myteam#fabrikam.org",
"useCustomAddress": true
}
}
Just set the the recipient email address in the "address": "xxxxx".
Note: You need provide the eventType and subscriber and so on.
My test result:
Related
I'm attempting to get the "Mail" property of related profile fields with a single API call from Azure Devops when pulling a work item.
API Call 1:
GET https://dev.azure.com/my-account/my-project/_apis/wit/workitems?ids=1234&$expand=all
...
"System.CreatedBy": {
"displayName": "John Doe",
"url": "https://spsprodcus1.vssps.visualstudio.com/the-id/_apis/Identities/entity1234",
"_links": {
"avatar": {
"href": "https://dev.azure.com/..."
}
},
"id": "1234...",
"uniqueName": "jdoe#mydomain.com",
"imageUrl": "https://dev.azure.com/...",
"descriptor": "aad...."
},
...
What i'm trying to find is the Mail attribute which you can obtain from the "url" field of the returned results of the first call:
API Call 2:
GET https://spsprodcus1.vssps.visualstudio.com/the-id/_apis/Identities/entity1234
...
{
...
"Properties": {
...
"DN": "",
"Mail": "johndoe#mydomain.com", # <--- THIS IS WHAT I WANT
"SpecialType": "Generic",
...
}
}
...
Is it possible to get both the work item information and the "Mail" attribute of related fields such as "CreatedBy" in API Call 1?
Thanks!
I have a requirement to dynamically add/remove or enable disable approval and checks at azure DevOps pipeline environment.
Is there a rest api for this?
Is there a rest api for this?
Yes, it has. BUT, as what the #Krysztof said, we haven't provide such api documents to public as of today. This is because what you are looking for is one feature (configure Check and approval from environments ) that only support for YAML pipeline, and until now, we are developing but does not publish the corresponding rest api (for YAML) docs.
But, as work around, you can catch these apis from F12. Just do action from UI, then capture and analyze corresponds api records to found out what you are expecting.
Here I make the summary to you.
The api that used to add/delete approval and check to environment is:
https://dev.azure.com/{org name}/{project name}/_apis/pipelines/checks/configurations
The corresponding api method for add or delete is Post and DELETE.
Firstly, share you the request body samples which for approval and check added.
1) Add approval to this environment:
{
"type": {
"id": "8C6F20A7-A545-4486-9777-F762FAFE0D4D", // The fixed value for Approval
"name": "Approval"
},
"settings": {
"approvers": [
{
"id": "f3c88b9a-b49f-4126-a4fe-3c99ecbf6303" // User Id
}
],
"executionOrder": 1,
"instructions": "",
"blockedApprovers": [],
"minRequiredApprovers": 0,
"requesterCannotBeApprover": false // The pipeline requester allow to approve it.
},
"resource": {
"type": "environment",
"id": "1", // Environment id
"name": "Deployment" //Environment name
},
"timeout": 43200 // Set the available time(30d) of this approval pending. The measure unit is seconds.
}
2) Add task check, Azure function, Invoke rest api task and etc:
{
"type": {
"id": "fe1de3ee-a436-41b4-bb20-f6eb4cb879a7", // Fixed value if you want to add task check
"name": "Task Check" //Fixed value
},
"settings": {
"definitionRef": {
"id": "537fdb7a-a601-4537-aa70-92645a2b5ce4", //task Id
"name": "AzureFunction", //task name
"version": "1.0.10" //task version
},
"displayName": "Invoke Azure Function", //task display name configured
"inputs": {
"method": "POST",
"waitForCompletion": "false",
"function": "csdgsdgsa",
"key": "436467543756" // These are all task inputs
},
"retryInterval": 5, // The re-try time specified.
"linkedVariableGroup": "AzKeyGroup"// The variable group name this task linked with
},
"resource": {
"type": "environment",
"id": "2",
"name": "Development"
},
"timeout": 43200
}
In this request body, you can find the corresponding task id from our public source code. Just check the task.json file of corresponding task.
3) Add template check:
{
"type": {
"id": "4020E66E-B0F3-47E1-BC88-48F3CC59B5F3", // Fixed value for template check added.
"name": "ExtendsCheck" //Fixed value
},
"settings": {
"extendsChecks": [
{
"repositoryType": "git", // github for Github source, bitbucket for Bitbucket source
"repositoryName": "MonnoPro",
"repositoryRef": "refs/heads/master",
"templatePath": "tem.yml"
}
]
},
"resource": {
"type": "environment",
"id": "6",
"name": "development"
}
}
In this body, if the template source is coming from github or bitbucket, the value of repositoryName should like {org name}/{repos name}.
Hope these are helps.
This is an older question but we had a similar need. There does not appear to be a direct API To query this, but this GitHub Project pointed us in the right direction:
# GET ENVIRONMENT CHECKS (stored under .fps.dataProviders.data['ms.vss-pipelinechecks.checks-data-provider'].checkConfigurationDataList)
GET https://dev.azure.com/{{organization}}/{{project}}/_environments/{{environment_id}}/checks?__rt=fps&__ver=2
As mentioned above under .fps.dataProviders.data['ms.vss-pipelinechecks.checks-data-provider'].checkConfigurationDataList the list of who is authorized is provided.
The officially documented APIs can tell you that there are checks in place; for example:
GET https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations?resourceType=environment&resourceId={id}
Can tell you that you have checks enabled (including an Approval check) but this isn't super useful as it does not give a list of who can Approve.
Note that you can get the list of environments (to get their resource ID) using this documented API:
GET https://dev.azure.com/{organization}/{project}/_apis/distributedtask/environments?api-version=7.1-preview.1
This is not supported at the moment. You can upvote feature request to show your interest here.
I have a workplace application,
I wish to change emailIds of the user via API,
I found that Account Management API
can be used to modify user details via API calls.
My use-case is to modify user email via the Account Management API, which comes under urn:scim:schemas:core:1.0 schema extension,
I wish to overwrite the existing email with the one I would specify in the requestBody,
From the documentation, I've come up with the following request -
Url endpoint -
https://someCompanyName.facebook.com/scim/v1/Users/ HTTP/1.1
Method type -
POST
Request body-
{
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:facebook:auth_method:1.0"
],
"userName": "abc",
"name": {
"formatted": "Julius Caesar"
},
"emails": ["abc#gmail.com"],
"urn:scim:schemas:extension:facebook:auth_method:1.0": {
"auth_method": "password"
}
}
Is it correct? What modifications do I need to make to the request?
in order to change the emails of a user you have to do a PUT request to the address https://www.facebook.com/scim/v1/Users/{userId}
and you have to change in your payload the email address:
{
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:extension:facebook:auth_method:1.0"
],
"userName": "abc",
"name": {
"formatted": "Julius Caesar"
},
"emails": [
{
"primary": true,
"type": "work",
"value": "newemail#gmail.com"
}
],
"urn:scim:schemas:extension:facebook:auth_method:1.0": {
"auth_method": "password"
}
}
Hope it helps
The request to
POST v1.0/groups
with the body:
{
"description": "hello",
"displayName": "group_for_restore",
"groupTypes": [
"Unified"
],
"mailEnabled": true,
"mailNickname": "group_for_restore",
"securityEnabled": false,
"visibility": "Public"
}
returns the id of the created group. But on the web interface this group does not appear.
That is why the request to
POST v1.0/planner/plans
with the body:
{
"owner": "{group-id}", // from the request above
"title": "group_for_restore"
}
returns such JSON:
{
"error": {
"code": "",
"message": "You do not have the required permissions to access this item, or the item may not exist.",
"innerError": {
"request-id": "d6d74776-e4cc-4cb2-bf87-20e3510b6f8c",
"date": "2018-03-27T14:39:00"
}
}
} (status code 403)
So it seems to me that it failed to create whole group (with all necessary content). I was trying to wait (2-5 min ... when the group will appear on the web interface), after that I could easily create a plan.
How can I properly guess the time when a group will be created or which request should be sent to check that it has been created successfully?
You shouldn't "guess", instead use periodic polling.
After creating the group, try polling groups/{id}/drive in 2-5 minute intervals. Once the Drive is available the Group has been provisioned.
Using the Google Calendar API, I can get all the attendees of the events with GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId.
In my calendar event, I use an alias team#mycompany.com which sends emails to the entire team organization. Unfortunately, my calendar event returns the alias, and not the individual emails, like this:
"attendees": [
{
"email": "me#mycomapny.com",
"self": true,
"responseStatus": "accepted"
},
{
"email": "team#mycomapny.com", <-- Not what I want
"displayName": "My Entire Company",
"responseStatus": "needsAction"
},
],
How do I get the expanded list of attendees, like this:
"attendees": [
{
"email": "me#mycomapny.com",
"self": true,
"responseStatus": "accepted"
},
{
"email": "you#mycomapny.com", <-- expanded email list
"responseStatus": "needsAction"
},
{
"email": "someoneelse#mycomapny.com",
"responseStatus": "needsAction"
},
{
"email": "manager#mycomapny.com",
"responseStatus": "needsAction"
},
... etc
],
I use an alias team#mycompany.com which sends emails to the entire team organization.
If you are adding team#mycompany.com to the event then that is exactly what you are adding. Calendar has no way of knowing that email is a mailing list. If you want each person to be listed then you are going to have to add each person to the event. Google calendar can only return the information that you give it.
Answer: Don't use a mailing list when creating the event add each user. Otherwise Google calendar has no way of knowing this is a mailing list. As i see it google calendar is returning the correct data.