Delphix automation using REST

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • In Progress
I am new to using REST.  I am confortable using delphix CLI to sutomate. However , can't see what is wrong with my rest program. 

Here is the code :


# Create API session
echo "Initiate Session "

curl -s -S -X POST -k --data @- \
-c ~/cookies.txt -H "Content-Type: application/json" <<EOF
 "type": "APISession",
 "version": {
 "type": "APIVersion",
 "major": 1,
 "minor": 7,
 "micro": 0

echo "Initiated Session"

# login
curl -s -S -X POST -k --data @- \
 -b ~/cookies.txt -H "Content-Type: application/json" <<EOF
 "type": "LoginRequest",
 "username": "amathe01",
 "password": djsdlfjdo_23"

# List ENV
echo "\n\n List Env Information"
curl -S -X GET -k \
 -b ~/cookies.txt -H "Content-Type: application/json"


When executing the script it only executed the first CURL and returns to command prompt. 
However, I can execute each command from the script on the command line and get the 
expected output. What am I missing?

Here is the output :
Initiate Session

A second question. Is there way not to send clear test password to the login request? Delphix CLI provides an encryption mecahnism. 

Thanks in advance !

Photo of Ansamma Mathews

Ansamma Mathews

  • 292 Points 250 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of Adam Bowen

Adam Bowen, Official Rep

  • 18,596 Points 10k badge 2x thumb
Start by looking at my example here:

To your second question, you are using curl in your rest calls. Here is an article that speaks to how to pass passwords to curl commands:

You would also need toResearch how toUse SSL with curl If you don't want to transmit information in plaintext.

If you're just doing some ad hoc scripts for yourself,Then maybe this is worthwhile.But, if you're going to do actual enterprise automation,You should really look into using a robust programming language like Python or golang
Photo of Ansamma Mathews

Ansamma Mathews

  • 292 Points 250 badge 2x thumb
Thank you Adam ! Perfect !!