Hiya Tina!

I think it's because your request body is missing the `name` attribute for
the pipeline. When updating a pipeline config resource this should be the
same as that within the URI path (i.e "hi" in your example).

The *parameter* is used to find the existing resource "hi" in your config.
However, to determine intent and apply restrictions to what can be altered,
fields within the *JSON body* of the config is then compared to what is
currently stored on the GoCD Server. Since the names are different (null <>
"hi") GoCD thinks you are trying to rename it (or remove the name!?). At
this stage in the validation it ignores that you haven't actually specified
the name.

https://github.com/gocd/gocd/blob/67fbd63486f5ac819c74e63996ee8ef7ba3763dd/api/api-pipeline-config-v11/src/main/java/com/thoughtworks/go/apiv11/admin/pipelineconfig/PipelineConfigControllerV11.java#L118-L123

https://github.com/gocd/gocd/blob/67fbd63486f5ac819c74e63996ee8ef7ba3763dd/api/api-pipeline-config-v11/src/main/java/com/thoughtworks/go/apiv11/admin/pipelineconfig/PipelineConfigControllerV11.java#L228-L230

Try specifying the name, e.g

{
    "group": "test",
*    "name": "hi,*
// ...

-Chad

On Tue, Aug 20, 2024 at 3:09 PM Tina Boyce <luong.t...@gmail.com> wrote:

> Hi,
>
> I am trying to update the pipelines and I am receiving the following 422 -
> Unprocessable Entity error message, "Renaming of pipelines is not supported
> by this API.".
>
> I was not sure whether I am missing something vital or is it an issue so
> I'd thought to raise it here first.
>
> I have a pipeline with the following details:
> - group: test
> - name: hi
>
> I have done the following:
> 1. Do a `GET /go/api/admin/pipelines/hi` request to obtain the latest ETag
> value
> 2. Do a `PUT /go/api/admin/pipelines/hi` with the ETag value in the
> If-Match request header
>
> Then I received the following error
> ```
> {
>     "message": "Renaming of pipelines is not supported by this API."
> }
> ```
>
> The request body for the `PUT /go/api/admin/pipelines/hi` request is:
> ```
> {
>     "group": "test",
>     "pipeline": {
>         "label_template": "${COUNT}",
>         "lock_behavior": "lockOnFailure",
>         "materials": [
>             {
>                 "attributes": {
>                     "url": "
> https://github.com/gocd-contrib/getting-started-repo";,
>                     "branch": "master",
>                     "shallow_clone": true,
>                     "auto_update": true
>                 },
>                 "type": "git"
>             }
>         ],
>         "stages": [
>             {
>                 "name": "default_stage",
>                 "fetch_materials": true,
>                 "clean_working_directory": false,
>                 "never_cleanup_artifacts": false,
>                 "approval": {
>                     "type": "success",
>                     "authorization": {
>                         "roles": [],
>                         "users": []
>                     }
>                 },
>                 "environment_variables": [],
>                 "jobs": [
>                     {
>                         "name": "defaultJob",
>                         "run_instance_count": null,
>                         "timeout": 0,
>                         "environment_variables": [],
>                         "resources": [],
>                         "tasks": [
>                             {
>                                 "type": "exec",
>                                 "attributes": {
>                                     "run_if": [
>                                         "passed"
>                                     ],
>                                     "command": "ls",
>                                     "working_directory": null
>                                 }
>                             }
>                         ],
>                         "artifacts": []
>                     }
>                 ]
>             }
>         ]
>     }
> }
> ```
>
> --
> You received this message because you are subscribed to the Google Groups
> "go-cd" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to go-cd+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/go-cd/bbfb9997-0877-4abc-a8f9-5d82ef62d8dan%40googlegroups.com
> <https://groups.google.com/d/msgid/go-cd/bbfb9997-0877-4abc-a8f9-5d82ef62d8dan%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to go-cd+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/go-cd/CAA1RwH8%2B2ADcA6Uxi4L_%3DuvHBZ%3DKyy87S3Uz1GENRoeYgsbo4w%40mail.gmail.com.

Reply via email to