I am trying to integrate Servicenow with Azure Devops Board to create/update etc etc on a work item using REST APIs
I was successful in creating and updating lot of things on the workitems
I am not able to find an API which tells the workitem to fall in a specific Swimlane
If you look in to the image I have attached, which has a default swimlane(test) and custom ones... so H have an api which moves it from "ToDo" to "Doing", but if you notice there multiple "Doing" as there are different swimlanes, so can anyone please help what the trick is or an API which tells the workitem to fall in a specific SwimLane
I did some research and found "System.BoardLane" I did use that in post and patch
ERROR:
{
"$id": "1",
"customProperties": {
"ReferenceName": null
},
"innerException": null,
"message": "TF401326: Invalid field status 'ReadOnly' for field 'System.BoardLane'.",
"typeName": "Microsoft.TeamFoundation.WorkItemTracking.Server.WorkItemFieldInvalidException, Microsoft.TeamFoundation.WorkItemTracking.Server",
"typeKey": "WorkItemFieldInvalidException",
"errorCode": 600171,
"eventId": 3200
}
then I used operation "op" :"move"
ERROR:
{
"$id": "1",
"innerException": null,
"message": "Move/Copy is not implemented.",
"typeName": "Microsoft.VisualStudio.Services.WebApi.Patch.PatchOperationFailedException, Microsoft.VisualStudio.Services.WebApi",
"typeKey": "PatchOperationFailedException",
"errorCode": 0,
"eventId": 3000
}
Azure DevOps REST APIs FOR SWIMLANE
In fact, you were very close to the correct answer.
The first error you faced: TF401326: Invalid field status 'ReadOnly' for field 'System.BoardLane' has indicate that if you want to modify the SwimLane by updating the System.BoardLane field via API, we does not allow that because of its read-only.
(For those fields, not only System.BoardLane is read-only, but also the System.BoardColumn)
This is by designed.
In order to update the SwimLane, here you need to update the extension fields instead of System fields via the API.
Step1:
Call the Get - Boards API to get the information about the Board. In its response body, the extension field names will display under fields -> rowField.
Sample:
GET https://dev.azure.com/{org name}/{project name}/{team name}/_apis/work/boards/Stories?api-version=5.1
The reference names for these extension fields will include a GUID that is unique for the board(e.g. WEF_6623ED31B8E04C778FB1129D3239B1A7_Kanban.Lane).
Step2:
Call the Update - Work Items API, using the field names you got above as the path (e.g. /fields/WEF_6623ED31B8E04C778FB1129D3239B1A7_Kanban.Lane) and input the lane value as the name of the row you want to move the item into:
Sample:
PATCH https://dev.azure.com/{org name}/{project name}/_apis/wit/workitems/{WIT id}?api-version=5.1
Request body:
[
{
"op": "add",
"path": "/fields/WEF_6623ED31B8E04C778FB1129D3239B1A7_Kanban.Lane",
"from": null,
"value": "Lane for product team"
}
]
Lane for product team is one of the Swimlane.
Now, you would see that the work item moved into the corresponding lane you specified.
Note: The GUID of the extension fields is unique for the board. Different boards has different extension fileds GUID value.
The swimlane that is used is based on the status of the workitem (I believe the field you want is System.Status) If you update that value of the workitem, it should move the workitem into the appropriate swimlane.
You can configure your team's board settings to map statuses to the swim lanes you want. If you are using an standard board process, then it should be pretty straightforward mapping between statuses and swim lanes, but if you have customized work items you will need to apply that logic to your code(IE this new item should be in a status of X to show as doing)
Related
I am trying to list all Pull Requests associated with a Work Item but according to the Work Items API there doesn't seem to be a way to get it:
GET https://dev.azure.com/{org}/{project}/_apis/build/builds/123456/workitems?api-version=6.0
The above returns list of work items, such as:
{
"count": 40,
"value": [
{
"id": "156267",
"url": "https://dev.azure.com/xxx/_apis/wit/workItems/12345"
},
...
]
}
Now, if I still decide to query each returned work item I still don't see a Pull Request.
For example:
GET https://dev.azure.com/xxx/_apis/wit/workItems/12345
The above returns a JSON object about updates done to the workitem, but this can be a commit, state update or comments.
Is there a way to get a list of PRs per work item?
Thanks
You need to add &$expand=relations:
GET https://dev.azure.com/xxx/_apis/wit/workItems/12345?$expand=relations
Now in the response you will get the linked PR under the relations.
I have installed following plugin to support multi-value type field in Azure DevOps
https://marketplace.visualstudio.com/items?itemName=ms-devlabs.vsts-extensions-multivalue-control#:~:text=Azure%20Devops%20Services,used%20to%20back%20the%20extension.
I am able to set the option for this field by separating using "semicolon". like "A; B; C"
I can also see this field in my work item and able to set the values.
I need help with how can I update this multivalue type field through REST API.
I want to change the value of the work item which has this multi-value type field through REST API. I have already tried updating them using the following approaches
"A; B"
"A, B"
"[A, B]"
"A;B"
"A,B"
It sets up the value which I am sending using option 4, but it adds those as an extra option though the option already exists with that value. I can see extra spaces on the option which I am sending through REST AP{I, but I have checked my JSON there is no extra space (using option 4).
I add a new work item field Multivalue control Test and configure Multivalue control
We could get the work item details via the REST API Work Items - Get Work Item:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0
And we could check the value of field Custom.MultivaluecontrolTest
Result:
Then we could update the value via the REST API Work Items - Update to update the value.
PATCH https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0
Sample request body:
[
{
"op": "test",
"path": "/rev",
"value": 7
},
{
"op": "add",
"path": "/fields/Custom.MultivaluecontrolTest",
"value": "A;B;C"
}
]
Result:
The filed value format is A;B;C, same as UI
I'm using FHIR R4 with Hapi FHIR API.
I want to know how marked the ServiceRequest resources with information about created user.
I've read the FHIR documentation and I've found the relevantHistory tag where I can put there a Provenance reference.
All good but the HAPI Fhir can't query that field/tag so I can't get all ServiceRequests created by me or another user.
I've also tried to use a customize extension named tracking, where I've put the tracking user info.
I don't want to use a requester tag because, it is filled with other guide line meaning supplied by customer
EDIT AFTER Mirjam Baltus
Hi,
interesting your point of view but, I've found another solution as follow, I want to discuss it with you (if you want).
I've added a SearchParameter resource attached on ServiceRequest to allow the search on relevantHistory field.
This is the JSON resource:
{
"resourceType": "SearchParameter",
"id": "6589",
"meta": {
"versionId": "7",
"lastUpdated": "2021-02-25T11:25:25.549+00:00",
"source": "#1btUOFbG0D3dMdwI"
},
"title": "Storia",
"status": "active",
"code": "relevantHistory",
"base": [
"ServiceRequest"
],
"type": "reference",
"expression": "ServiceRequest.relevantHistory",
"xpathUsage": "normal",
"target": [
"Provenance"
],
"modifier": [
"missing"
],
"chain": [
"reference"
]
}
So I've written a query on ServiceRequest filtered by relevantHistory field (linked to Provenance).
I've adopted this strategy because I need to know only the creator of ServiceRerquest, so in this way, I've factorized the information in Provenance resource where in the target field I've put the Practitioner / Organization who created the ServiceRequest and in the agent component I've replicated this information with ENTERER value in the enum AgentRole and AgentType.
In this way, I've collected one Provenance for more ServiceRequests, instead If I follow your way, I'll have for each ServiceRequest a dedicated Provenance.
You think I've followed a wrong way or it is a possible solution?
The relevantHistory is not the right field to use, since that will only list older Provenance resources that hold relevant information. The description specifically says it does not hold the Provenance resource associated with the current version of the ServiceRequest (see http://hl7.org/fhir/servicerequest-definitions.html#ServiceRequest.relevantHistory).
I think Provenance can still help you. You would not search on a field in ServiceRequest, but find ServiceRequests that have a Provenance where you/user are the actor:
GET [base]/ServiceRequest?_has:Provenance:target:actor=[user_reference]
Or approach it the other way around, by looking for Provenance resources from the user, and including ServiceRequests that are the target of the Provenance.
Added after edit of original post:
As I mention in my comment, I think the way you are trying to use the relevantHistory field and one Provenance for multiple ServiceRequests is not according to how that field and resource type are supposed to be used.
If you are able to create a custom search parameter, why not use an extension on the ServiceRequest to indicate who created it, and then make that extension searchable?
If you want more discussion about this, please ask on https://chat.fhir.org, where more people from the FHIR community will be able to chime in.
I am trying to create a state for existing work item.
For Get, the url will show the list of States under Bug.
But am facing an issue when I do Post with json.
https://{server}/{collection}/_apis/work/processes/{processid}/workItemTypes/Microsoft.VSTS.WorkItemTypes.Bug/states?api-version=5.0-preview.1
Json:
{"name": "Test-Status", "color": "007acc", "stateCategory": "InProgress", "order": 3 }
Below is the error details
Http - 404 - NotFound
{ "$id": "1", "innerException": null, "message": "VS402805: Cannot
find work item type with reference name
'Microsoft.VSTS.WorkItemTypes.Bug' in process named
'dcdcc713-ebc6-4940-aa9d-d6c9d3e00e39'.", "typeName":
"Microsoft.TeamFoundation.WorkItemTracking.Server.Metadata.ProcessWorkItemTypeDoesNotExistException,
Microsoft.TeamFoundation.WorkItemTracking.Server", "typeKey":
"ProcessWorkItemTypeDoesNotExistException", "errorCode": 0, "eventId":
3200 }
Any help regarding this is appreciated.
The problem should be:Microsoft.VSTS.WorkItemTypes.Bug. I think you need use the format like processName.typeName. In addition the original process cannot be customized , only the inherited process can be customized.
Here I test your api in postman,it can work well.
I had the same problem.
When you create a new process, all the Work Item Types from the Parente process (Agile, Scrum, etc.) starts with the Microsoft.VSTS.WorkItemTypes.(Epic, Bug, etc.) and you can't modify it, you will have the error:
"VS402805: Cannot find work item type with reference name 'Microsoft.VSTS.WorkItemTypes.Bug' in process name ..."
To solve this, you just need to create a new work item type that inherits that work item type that you want to use, post example:
POST https://dev.azure.com/{organization}/_apis/work/processes/{processId}/workitemtypes?api-version=6.0-preview.2
{
"referenceName": "ProcessName.Issue",
"name": "Issue",
"description": "your description",
"color": "B4009E",
"icon": "icon_traffic_cone",
"inheritsFrom": "Microsoft.VSTS.WorkItemTypes.Issue"
}
I hope it helps.
Have a nice day!
I am using TFS REST APIs to fetch the workitems info and for other operations. When I use the instructions mentioned on the URL listed below to get the workitem details, JSON which is coming back has all the info related to this workitem but it is missing the "relations" section in it. I have defined parent and child relations for this workitem which I am querying. have tried different querystring options for "expand" such as relations and all.
https://www.visualstudio.com/en-us/docs/integrate/api/wit/work-items#with-links-and-attachments-1
Would really appreciate any guidance on how to fetch the info about related workitems.
First double check if you are using the correct Rest API with right format, you just need to use get a work item With links and attachments API, sample request:
GET http://xxx:8080/tfs/DefaultCollection/_apis/wit/workitems/4?$expand=relations&api-version=1.0
In the json response, should include relations such as below:
"relations": [
{
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "http://xxx:8080/tfs/DefaultCollection/_apis/wit/workItems/7",
"attributes": {
"isLocked": false
}
},
{
"rel": "System.LinkTypes.Hierarchy-Forward",
"url": "http://xxx:8080/tfs/DefaultCollection/_apis/wit/workItems/10",
"attributes": {
"isLocked": false
}
}
],
System.LinkTypes.Hierarchy-Reverse stands for parent, and System.LinkTypes.Hierarchy-Forward stands for child.
If you still cannot get the info, go through the links of that specifical work item in the web to see if you have added parent and child relations for this workitem successfully.