Azure devops boards REST API - move ticket between columns - azure

I'm testing out the Azure Boards rest API. I can currently create, delete and get items successfully, however I can't seem to move them between columns.
This is my request
https://{{AzureBoardsToken}}#{{AzureBoardsPath}}/_apis/wit/workitems/8907?api-version=6.0-preview.3
with a payload of
[
{
"op": "move",
"path": "{no idea what to put here}",
"from": "{no idea what to put here}",
"value": "{not sure if this is relevant for this operation}"
}
]
I don't find the documentation particularly useful as it assumes you know what those properties mean and where to get them.
Any help would be highly appreciated! The idea is to then integrate it in nodejs

Solution 1
To move workitem to another column you have to change "WEF_{id}_Kanban.Column" field.
Use PATCH to update your workitem with body:
[
{
"op": "replace",
"path": "/fields/WEF_F9DCD9224F6E466499435017DB7D2D07_Kanban.Column",
"value": "<column name>"
}
]
Solution 2
To move workitem to another column you have to change it "state". This only works if you assigned that state to the column.
Use PATCH to update your workitem with body:
[
{
"op": "replace",
"path": "/fields/System.State",
"value": "<column name>"
}
]
doc: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/update?view=azure-devops-rest-6.0
EDIT (Adding new state):
Go to organization settings -> Process -> choose your workflow -> choose item type -> states -> new state (Add "In progress" here)
Tutorial: https://learn.microsoft.com/en-us/azure/devops/organizations/settings/work/customize-process-workflow?view=azure-devops#add-a-workflow-state
Then go to column setting on Kanban Board and associate new state with column
Tutorial: https://learn.microsoft.com/en-us/azure/devops/boards/boards/add-columns?view=azure-devops#update-kanban-column-to-state-mappings
After that try using API REST to change state, it should work

To alter the System.State of a task I had to alter the System.Reason as well. For some reason the two fields are connected and both changes are necessary to trigger a transition from one column to the other.
For example to change a task from the state To Do to In Progress use the Work Items - Update REST API with the following request body:
[
{
"op": "replace",
"path": "/fields/System.State",
"value": "In Progress"
},
{
"op": "replace",
"path": "/fields/System.Reason",
"value": "Work started"
}
]

Related

How to get any field in devops using logic apps?

I am creating a logic app which will update the tags column in Azure DevOps with some value.
So how do I fetch that column into my logic apps so that I can update the values on that columns.
This is easiest achieved using the code view. Firstly, Tags are not by default output as array, rather they are a string like:
"System_Tags": "MyTag1; MyTag2"
So, you'll also need to construct the array from that string using a split.
I have here a sample of how to initialize a variable using the result of a Get Work Item Details from Azure Devops:
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Work item tags",
"type": "array",
"value": "#split(body('Get_work_item_details')?['fields']?['System_Tags'], '; ')"['System_Tags']}"
}
]
},
"runAfter": {
"Get_work_item_details": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
This will initialize your new variable with the tags of the queried work item.

Forge-Get Item Path along with custom attributes in BIM360 document

Two Requirements are needed:
Get item path of the document in a BIM360 document management.
Get all custom attributes for that item.
For Req. 1, an api exists to fetch and for getting custom attributes, another api exists and data can be retrived.
Is there a way to get both the requirements in a single api call instead of using two.
In case of large number of records, api to retrieve item path is taking more than an hour for fetching 19000+ records and token gets expired though refesh token is used, while custom attribute api processes data in batches of 50, which completes it in 5 minutes only.
Please suggest.
Batch-Get Custom Attributes is for the additional attributes of Document Management specific. While path in project is a general information with Data Management.
The Data Management API provides some endpoints in a format of command, which can ask the backend to process the data for bunch of items.
https://forge.autodesk.com/en/docs/data/v2/reference/http/ListItems/
This command will retrieve metadata for up to 50 specified items one time. It also supports the flag includePathInProject, but the usage is tricky and API document does not indicate it. In the response, it will tell the pathInProject of these items. It may save more time than iteration.
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "commands",
"attributes": {
"extension": {
"type": "commands:autodesk.core:ListItems",
"version": "1.0.0" ,
"data":{
"includePathInProject":true
}
}
},
"relationships": {
"resources": {
"data": [
{
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:vkLfPabPTealtEYoXU6m7w"
},
{
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:bcg7gqZ6RfG4BoipBe3VEQ"
}
]
}
}
}
}
Get item path of the document in a BIM360 document management.
Is this question about getting the hiarchy of the item? e.g. rootfolder>>subfolder>>item ? With the endpoint, by specifying the query param includePathInProject=true, it will return the relative path of the item (pathInProject) in the folder structure.
https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-items-item_id-GET/
"data": {
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:xxx",
"attributes": {
"displayName": "my-issue-att.png",
"createTime": "2021-03-12T04:51:01.0000000Z",
"createUserId": "xxx",
"createUserName": "Xiaodong Liang",
"lastModifiedTime": "2021-03-12T04:51:02.0000000Z",
"lastModifiedUserId": "200902260532621",
"lastModifiedUserName": "Xiaodong Liang",
"hidden": false,
"reserved": false,
"extension": {
"type": "items:autodesk.bim360:File",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/items:autodesk.bim360:File-1.0"
},
"data": {
"sourceFileName": "my-issue-att.png"
}
},
"pathInProject": "/Project Files"
}
or if you may iterate by the data of parent
"parent": {
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:fs.folder:co.sdfedf8wef"
},
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.project.id.xyz/items/urn:adsk.wipprod:dm.lineage:hC6k4hndRWaeIVhIjvHu8w/parent"
}
}
},
Get all custom attributes for that item. For Req. 1, an api exists to fetch and for getting custom attributes, another api exists and data can be retrived. Is there a way to get both the requirements in a single api call instead of using two. In case of large number of records, api to retrieve item path is taking more than an hour for fetching 19000+ records and token gets expired though refesh token is used, while custom attribute api processes data in batches of 50, which completes it in 5 minutes only. Please suggest.*
Let me try to understand the question better. Firstly, two things: Custom Attributes Definitions, and Custom Attributes Values(with the documents). Could you clarify what are they with 19000+ records?
If Custom Attributes Definitions, the API to fetch them is
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/document-management-custom-attribute-definitions-GET/
It supports to set limit of each call. i.e. the max limit of one call is 200, which means you can fetch 19000+ records by 95 times, while each time calling should be quick (with my experience < 10 seconds). Totally around 15 minutes, instead of more than 1 hour..
Or at your side, each call with 200 records will take much time?
If Custom Attributes Values, the API to fetch them is
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/document-management-versionsbatch-get-POST/
as you know, 50 records each time. And it seems it is pretty quick at your side with 5 minutes only if fetch the values of 19000+ records?

How do I add a link between azure devops work item and a git branch with the node api?

I am trying to update a work item in azure devops with a linked branch in my repo. I'm using the azure-devops-node-api. Currently i'm trying to update the field "relations", but im not sure thats correct.
if (linkUrl) {
azureUpdateArr.push({
op: "add",
path: "/relations/-",
value: {
rel: "ArtifactLink",
url: linkUrl,
attributes: {
name: "Branch",
comment: "Making a new link for the branch",
},
},
});
}
await api.updateWorkItem({}, azureUpdateArr, Number(workItem.Number));
The azureUpdateArr is a json patch doc, so i'm just trying to add an operation to add a relation, but i'm not sure what the rel: should be, or indeed anything else.
i'm not sure what the rel: should be, or indeed anything else.
Based on my test, if you need to link a git branch to the Work item , the rel type is ArtifactLink.
As is shown in your code, the rel could be correct.
I refer to this doc about Rest API: Work Items - Update.
Here is my Request Body sample:
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "ArtifactLink",
"url": "vstfs:///Git/Ref/{Project ID}/{Repo ID}/GB{Branch name}",
"attributes": {
"name": "Branch",
"comment": "test link branch"
}
}
}
Result:
Note: you need to use GB+Branch name format in the url field. Or it seems that the branch couldn't be linked successfully.
Hope this helps.

Filter Query (OData) in Logic App

I am trying to create a simple logic app to send email if the a field is true.
The flow is:
Get Items From SPO (1) > Filter Array (2) > Send Email (3)
(1): This step, I want to have a quick filter to limit records returned from SharePoint Online:
"queries": { "$filter": "preproccessed eq true" }
(2)(3): another filter applied, then send email
The (2) & (3) run just fines, but the (1) doesn't work at all, all records returned regardless of the filter. I even tried this:
"queries": { "$filter": "preproccessed eq 1" }
But it doesn't work.
Anyone has any ideas what I missed here?
Thank you.
Currently the OData filter is not supported correctly by the SharePoint Online connector, resulting in all rows being returned regardless of the specified filter condition.
As a workaround, you can use the Filter array card to filter the records in the Logic App itself (or use the Query action type if you are authoring your logic directly in code view).
{
"type": "Query",
"inputs": {
"from": "#body('Get_items')?['value']",
"where"": "#equals(item()?['preproccessed']?['Value'], 1)"
},
"runAfter": { "Get_items": [ "Succeeded" ] },
}

Insert a card that can be directly responded to

update !important: The API has changed a lot, this question shouldn't be taken into consideration anymore
I am trying to use the REST api (via Node.js API) to create cards that the user can respond to and create an interaction in this way.
Reading the docs the creator attribute is not really specified anywhere, so I have no idea how to insert that.
Also this video doesn't help. Nor this guide =)
I believe there is an URL I should set as callback somehow? I'd like to know how to get these responses, please.
update
This is the card I am sending.
{
bundleId: 'veryuniqueBundle',
id: 'veryuniqueBundle:reply',
text: "want to hear moar?",
menuItems: [
{action: "REPLY"}
]
}
that's the response I get:
{
"collection": "timeline",
"itemId": "119c4dc8-c0ce-4a83-aa76-41aab4e8dbe1",
"operation": "INSERT",
"verifyToken": "42",
"userToken": "id:520ef63cde31145deb000001",
"userActions": [
{
"type": "REPLY"
}
]
}
The problem is, I can't see what the user responded (an text) and the reference to the original card id (or bundle) that was responded to. How can I get those
Cards do not provide a direct callback. Instead, when a user selects a menu item it causes the card to be updated with their menu selection. This change subsequently triggers a notification ping to your timeline subscription.
Follow these steps to detect a menu item selection:
Subscribe to notifications for changes in the timeline collection
{
"collection": "timeline",
"userToken": "awesome_kitty",
"verifyToken": "random_hash_to_verify_referer",
}
Insert a timeline card with a custom menu item
{
"text": "Hello world",
"menuItems": [
{
"action": "CUSTOM",
"id": "complete"
"values": [{
"displayName": "Complete",
"iconUrl": "http://example.com/icons/complete.png"
}]
}
]
}
Select the item on Glass
Receive the notification on your subscription URL
{
"collection": "timeline",
"itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",
"operation": "UPDATE",
"userToken": "harold_penguin",
"userActions": [
{
"type": "CUSTOM",
"payload": "PING"
}
]
}
Do cool stuff in your code
???
Profit

Resources