First of all, you may want to consider changing the password, since you
provided us the username and password encoded as base64 :)

On Wed, Sep 28, 2016 at 4:46 PM Carl Reid <[email protected]> wrote:

> Trying to add an existing pipeline to an environment using the new environment
> config API <https://api.go.cd/current/#environment-config>.
>
> The method is PATCH.
>
> I have tried this in PowerShell and in Curl and the error is the same.
>
> 412 PreCondition Failed.
>
> In addition, in Curl you see the following message: "Someone has modified
> the configuration for environment 'Commit'. Please update your copy of the
> config with the changes."
>

I'm able to run this just fine. What version of gocd are you on? This API
was only introduced in 16.10.0

$ curl --netrc https://build.go.cd/go/api/admin/environments/internal  -H
'Accept: application/vnd.go.cd.v1+json' -XPATCH -H 'Content-Type:
application/json' -d '{"pipelines":{"add":["Test_Golang_agent"]}}' -i

HTTP/1.1 200 OK
Date: Wed, 28 Sep 2016 11:24:45 GMT
…
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/vnd.go.cd.v1+json; charset=utf-8
Cache-Control: max-age=0, private, must-revalidate
ETag: "2c4715781d9ebf8529ddb00d93971bdc"

{
  "_links": {
    "self": {
      "href": "https://build.go.cd/go/api/admin/environments/internal";
    },
    "doc": {
      "href": "https://api.go.cd/#environment-config";
    },
    "find": {
      "href": "
https://build.go.cd/go/api/admin/environments/:environment_name";
    }
  },
  "name": "internal",
  "pipelines": [

Looking at the example <https://api.go.cd/current/#update-an-environment>,
> in an environment update call (which uses PUT) there is an additional
> header required it seems from the example curl request
>
> If-Match: "26b227605daf6f2d7768c8edaf61b861"
>
> There is no explanation of what this header is used for and why it needs
> to present and it is not there in the PATCH example.
>

This is required in order to avoid the “lost update” problem, where a
client `GET`s a resource's state, modifies it and `PUT`s it back to the
server, while another user has modified the state of the same resource,
leading to a conflict.

The patch call, since it's a delta, does not require conflict resolution,
so the If-Match header is not needed.

We missed documenting that in the environment update call, will fix the
documentation.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to