EDIT: added a new version of the powershell script with redundant lines removed
I’m trying to modify a project’s deployment process via the REST API but i’m getting a generic “400 - bad request” response, and no entries in the Octopus Server logs. It’s possibly I’m misunderstanding how this endpoint works but without any error messages it’s impossible to troubleshoot. I’ve taken some guidance from previous topics on this issue but none of them had any resolution.
My code is attached, here is a description of what it’s doing;
Get the deployment process template. In my case is this is the deployment process for a brand new project so contains no steps or actions.
Get an action template from a different deployment process. This is a fairly simple scripted step based on a custom step template.
Add the action template to the deployment process retrieved in step 1.
Update the deployment process with Put.
Step 4 results in this exception;
Invoke-WebRequest : The remote server returned an error: (400) Bad Request. At E:\resources\scripts\powershell\wip\dep_proc_poc.ps1:26 char:29 + ... ntProcess = Invoke-WebRequest -Uri "http://octopus.app.branch.local/a ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
If i skip step 3 (no changes) then there is no error. But it seems that any modification to the deployment process before issuing the Put will result in a generic 400 response.
Any advice appreciated!
dep_proc_poc_fixed.ps1 (1.0 KB)