Laurent Michel
Laurent Michel

Reputation: 1321

How to delete a Jelastic environment through the API?

I tried to delete one of my Jelastic environments by means of the following API call:

curl -k \ 
-H "${CONTENT_TYPE}" \ 
-A "${USER_AGENT}" \ 
-X POST \ 
-fsS ${HOSTER_URL}/1.0/environment/control/rest/deleteenv -d "password=${password}&session=${session}&envName=${envName} 

where I am sure that the session and envName are correct, as I have other commands running perfectly well with them. In particular, I get the session in the following way:

getSession() { 
  local login=$1 
  local password=$2 
  local hosterUrl=$3 
  echo "Signing in..." >&2 
  local cmd=$(curl -k -H "${CONTENT_TYPE}" -A "${USER_AGENT}" -X POST \ 
    -fsS "$hosterUrl/1.0/users/authentication/rest/signin" -d "login=$login&password=$password"); 
  exitOnFail $cmd 
  echo "Signed in" >&2 
  echo $(jq '.session' <<< $cmd | sed 's/\"//g') 
} 

In the call to deleteenv, I provide the very same password as that of my Jelastic provider account. Indeed, when I want to delete an environment through Jelastic's dashboard, this is the password I need to provide to make the deletion happen. However, I get the following error:

{"result":801,"source":"hx-core","error":"invalid password"} 

Because the password field is documented as optional in Jelastic's API documentation, I tried not to set the password. This yields the following error:

{"result":3,"source":"JEL","error":"invalid parameter [password] for method [DeleteEnv] in service [ControlService]"} 

I tried to use other secrets as that password, like the APPID, without any success.

Does anyone have a clue what password I need to put there?

Upvotes: 0

Views: 173

Answers (1)

Virtuozzo
Virtuozzo

Reputation: 1993

We used the same oneliner based on API you used, your script to get a session and the same Jelastic version but were not able to reproduce this issue. Environment were successfully deleted.

Does anyone have a clue what password I need to put there?

This is the same password as you used to get session or to enter Dashboard. Make sure there are no additional symbols in your password variable.

Because the password field is documented as optional

Indeed, it's optional if use token instead of session. In case of session, password is an obligatory parameter.

Upvotes: 1

Related Questions