Deleting environment via rancher api is not working


I’m trying to delete an environment through Rancher API and getting 404 error.

When I click delete in actions on one of the environments(project in API), it says no action is needed.

And so I posted the http request

-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{}’

to delete the environment but gettting the below error

HTTP Response:
HTTP/1.1 404
Date: Mon, 23 May 2016 05:36:47 GMT
Server: Jetty(9.2.11.v20150529)
X-Api-Account-Id: 1a1
Content-Type: application/json; charset=utf-8
Content-Length: 152
Expires: Thu, 01 Jan 1970 00:00:00 GMT

“id”: “c12f3875-8c9b-49fe-aea2-102735a055ff”,
“type”: “error”,
“links”: { },
“actions”: { },
“status”: 404,
“code”: “Not Found”,
“message”: “Not Found”,
“detail”: null,

Can anyone please tell me what I’m missing?

Thank you

Sounds like you’re using the API key of an environment instead of one for a user. Environments (projects) can’t manage other environments.

Hi Vincent,

That was right ,I was trying with Environment API key.

Now, I tried with account key and still getting error

curl -u “publicvalue:secretvalue” \

-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{}’

I got the public value and secret value by creating apikey in /v1/apikey for “admin” user and as well as the environment user “testenv2” which I’m trying to delete via API.

What am I missing?

delete isn’t an action… There is one called remove, but you should be using the HTTP method, curl -X DELETE ...

Thank you Vincent, appreciate your help, it’s working.