Probem to update deploymentprocess using API Rest

I have a code in ruby ​​to clone existing project base and from it update the deploymentprocess steps and i recieve this message:

"Changes to this deployment process could not be saved, because another user has made changes to the deployment process between when you started editing and when you saved your changes. Please reload or open a new tab to make your changes."

Whats happening?

my code ruby in attach file

Thanks

TestDeploymentProcess.rb (1 KB)

Hi Alex,

Thanks for reaching out and sorry for the delay. The JSON you are passing down on the PUT request doesnt have all the fields required by a deployment process.

What i would recommend you is to

  1. Do a GET on your template deployment process and assign that value to a variable
  2. Modify the values of that variable according to the needs of your new projects
  3. PUT the modified template on your new project.

Hope that helps!

Dalmiro

I’ve done some more research and have determined that I’ll need to do this via the REST API. I ran into a issue and found a post where it recommended that this be done:

  1. Do a GET on your template deployment process and assign that value to a variable
  2. Modify the values of that variable according to the needs of your new projects
  3. PUT the modified template on your new project.

So I’ve tried this

  1. $t = Invoke-WebRequest -Uri (“http://MYURL//api/deploymentprocesses/deploymentprocess-projects-155”) -Headers $Header

  2. Modified values I needed to

  3. Invoke-WebRequest -Uri (“http://MYURL//api/deploymentprocesses/deploymentprocess-projects-156”) -Method Post -Headers $Header -Body $t

And I’m getting this error in response:

“ErrorMessage”: “There was a problem with your request.”,
“Errors”: [
“Changes to this deployment process could not be saved, because another user has made changes to the deployment process between when you started editing and when you saved your changes. Please reload or open a new tab to make your changes.”

Am I still missing something? Thanks for the help!

Hi Matt,

Thanks for reaching out! I’d need see your script to help you out with this. Think you can send it over?

Thanks!

Dalmiro.

I’m trying to do the same thing…

$octoHeader = @{ "X-Octopus-ApiKey" = $apiKey }

# GET Source deployment process from Deployment Scaffold project
$t = Invoke-WebRequest -Uri ("http://server/octopus/api/deploymentprocesses/deploymentprocess-projects-100") -Headers $octoHeader

# Modify values as needed
# TODO 

# PUT modified deployment process in target project
Invoke-WebRequest -Uri ("http://server/octopus/api/deploymentprocesses/deploymentprocess-projects-101") -Method Put -ContentType "application/json" -Headers $octoHeader -Body $t

Which results in this error:

Invoke-WebRequest : Length Required
HTTP Error 411. The request must be chunked or have a content length.At C:\Users\slandsaw\Documents\Powershell Scripts\Octopus\OctoTest6.ps1:12 char:1
+ Invoke-WebRequest -Uri ("http://server/octopus/api/deploymentprocesses/depl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I’m also getting the “another user” error when trying to update the deployment process. I don’t see any resolution yet. Is this still being investigated?

As suggested above, I’m getting the JSON from a GET, modifying what I need to modify, and then sending it back to the server with a PUT. This a test project, and nobody else has access to it. Also, is there even any time between when I make changes and when I save them if I’m using the API? Aren’t those times, like, exactly the same instant?