Does azure devops support the retrieval of data from rest API and populate that data in the workitem fields
I tried writing powershell script to retrieve data from rest API and populate that data in workitem fields in azure devops
Does azure devops support the retrieval of data from rest API and populate that data in the workitem fields
I tried writing powershell script to retrieve data from rest API and populate that data in workitem fields in azure devops
On
After you retrieve the value from 3rd party rest api, you can parse the response to get the value wanted, then set the value to the field value in rest api below to update the work item.
The $fieldvalue is gotten from your 3rd party rest api as an example. The reference doc: Update a field.
$org = "orgname"
$witId = "workitemid"
$fieldvalue = "Active" # This is the value got from 3rd party rest api.
$token = "PAT"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$url="https://dev.azure.com/$org/_apis/wit/workitems/$witId" + "?api-version=7.0"
echo $url
$body = @(
@{
op = "add"
path = "/fields/System.State" # the field path
value = "$fieldvalue" # the field value
}
)
$head = @{ Authorization =" Basic $token" }
$response = Invoke-RestMethod -Uri $url -Method PATCH -Headers $head -Body (ConvertTo-Json -InputObject $body) -ContentType application/json-patch+json
Please make sure your account (which generated the PAT) has enough permission to edit the boards work item, you can simply set the account as contributor rule of the DevOps project.

does azure devops support dynamic retrieval of value from 3rd party rest API
To dynamically retrieve value from 3rd party rest api, you can consider to use DevOps pipeline, and could have options below:
You could need to monitor the change of the 3rd party rest api somehow, it depends on your 3rd party rest api, and then trigger devops pipeline, in pipeline you can get the value and update the work item value.
Or you can set schedule trigger on DevOps pipeline, so that the pipeline will automatically run in schedule to update the work item.
Yes, you can get the fields of
workItemsby calling the API below: -GET API: -
Reference1
And update the Fields by calling the API below: -
Update API:-
Reference2
There's one more API to update a particular field in WorkItem
Reference3 :-