Reputation: 21
I am trying to update release scoped variables for the existing release using API.
Issue: receiving exception on API call (PUT https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1-preview.8)
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"You are using an old copy of release. Refresh your copy and try
again.","typeName":"Microsoft.VisualStudio.Services.ReleaseManagement.Data.Exceptions.InvalidRequestException,
Microsoft.VisualStudio.Services.ReleaseManagement2.Data","typeKey":"InvalidRequestException","errorCode":0,"eventId":3000}
Steps to Recreate:
GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1-preview.8
"allowOverride"
set to truePUT https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1-preview.8
and providing json generated in steps 2-5I have updated 2 release properties (modifiedOn and definitionSnapshotRevision) because I saw that these values change if I update a release using web site (https://vsrm.dev.azure.com). It seems that I am still missing something. I cannot find any guidance in documentation on how to properly update a release deployment.
Upvotes: 2
Views: 1840
Reputation: 21
I used "Invoke-RestMethod" powershell commandlet to get release metadata. This commandlet returns custom ps object which I then updated, converted to json using "ConvertTo-Json" commandlet and provided in the body of the PUT HTTP request to DevOps to update the release. The issue is that Powershell serialization/de-serialization process of json does not result to the original json. For example this json property:
"preDeploymentGatesSnapshot": {
"id": 0,
"gatesOptions": null,
"gates": []
},
becomes:
"preDeploymentGatesSnapshot": "@{id=0; gatesOptions=; gates=System.Object[]}"
After I used correct json in the body of the PUT request in the API call:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1-preview.8
the release got successfully updated.
Upvotes: 0