Deleting environment via rancher api is not working

Hi,

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

curl -u “${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}”
-X POST
-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{}’
http://192.168.54.207/v1/projects/1a94/?action=delete

to delete the environment but gettting the below error

HTTP Response:
HTTP/1.1 404
Date: Mon, 23 May 2016 05:36:47 GMT
X-Api-Client-Ip: 192.168.54.113
Server: Jetty(9.2.11.v20150529)
X-Api-Account-Id: 1a1
Content-Type: application/json; charset=utf-8
X-Api-Schemas: http://192.168.54.207/v1/schemas
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” \

-X POST
-H ‘Accept: application/json’
-H ‘Content-Type: application/json’
-d ‘{}’
http://192.168.54.207/v1/projects/1a94/?action=delete
{“id”:“82380905-5862-4ede-ae53-88d4cb8fa6bd”,“type”:“error”,“links”:{},“actions”:{},“status”:422,“code”:“ActionNotAvailable”,“message”:null,“detail”:null,“fieldName”:“action”}

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 ... http://192.168.54.207/v1/projects/1a94

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