We have created many projects on our Octopus server and now I am attempting to delete most of them using the API I am able to run GET against the API without any problems but when attempting a DELETE I am getting a 400 error.
Example from log - First one is when using the web interface and the second is from calling the API
The 443 request is from a different server using the web interface. I was running the script on the actual server that hosts Octopus and won’t run on 443 hence the port 80. I did also try it from the server where I was using the web interface over 443 and it returned the same results. The actual delete Invoke-RestMethod came directly out of the API documentation.
I appreciate any help you can give. I am getting all of the project names and they are filtering correctly it is just the DELETE
I’ve was able to get your script it working on my end without making any changes to it so I can confirm it’s correct, however I was also getting a Bad Request when targeting an HTTP url while forcing HTTPS redirect: Expose the Octopus Web Portal over HTTPS | Documentation and Support
I did also try it from the server where I was using the web interface over 443
Just to confirm, you tested running the script using the HTTPS url from the instance that succeeded through the UI? It seems strange that this would also cause a Bad Request, are there any proxies in-between?
I’d be happy to check over the Octopus.Server logs for any clues if you’d like to send them through to our Secure Upload Portal or answer any questions you have!
I appreciate the help. I did go to the Octopus server itself and ran the Web UI from there and was able to also delete a project over port 80. We do not have the forced redirect checked nor do we have HSTS enabled
I uploaded some logs. You will notice there are two different users, I changed API keys just to see if it would make a difference. Looking at the web bindings I also noticed that localhost was being used. I attempted to use that, but received the same resiults.
Cheers for confirming that and providing the logs, is it just for the one project that you are seeing this error? Projects-375
If you try to delete it through the UI does it show the same error? I thought I recalled an old issue with deleting cloned projects but I haven’t been able to locate it, could you please send through the JSON returned for Projects-375 endpoint?
I’ll keep you posted with any other suggestions, looking forward to hearing how you get on!
If you navigate in the UI to the Project’s Deployment Settings, are you able to change the release versioning to use a template or specify a step and package to use instead?
Thank you for the reply
I can, but having to do this will not help. If I have to do this with every project I mine as well just go in and delete them by hand which is what I’m attempting to avoid by using the API in the first place. That versioning strategy is just the default as we don’t use it.
No problem at all, sorry I assumed it was just the single project!
The expected value for the Versioning Strategy using the default template should look like the following, which has an empty DonorPackage value, but not DonorPackageStepId which I think is causing the bad request:
I’ll put a script together for modifying projects to use the default json above however you might want to look into how these projects are being created with DonorPackageStepId so it can prevent it from being an issue in future.
Ahh sorry look like I was incorrect and 2019 works a bit differently with the DonorPackageStepId being included back then.
I’ll keep digging into this and see if I can spot what’s really causing the issue, I have a feeling it might be the clonedProject being referenced, has Projects-342 been removed already?
I’ll keep you posted with any updates on my end or if I have questions, feel free to do the same!
Well I think you are on to something. I switched out the filter to return just project 342 and it returned. but in the process it also deleted it (I didn’t comment out the delete). So now I wonder if it is just the first project causing the script to fail. I may filter out 375 and see if it works. I will let you know. For reference purposes this was the info for 342 before it was deleted:
That looks to have been it. I removed the permissions and was able to delete through the UI. There were only a couple of projects left so I did those manually.