Gundamaiah
Gundamaiah

Reputation: 786

How to write RESTful web services client based on curl

I need to write a RESTful web service client for Delphix.I am new to delphix and RESTful webservices.How can I write a client based on the below curl.

Create Delphix API Session

$ curl -s -X POST -k --data @- http://delphix-server/resources/json/delphix/session \ -c ~/cookies.txt -H "Content-Type: application/json" <

   Delphix Login 

$ curl -s -X POST -k --data @- http://delphix-server/resources/json/delphix/login \

-b ~/cookies.txt -H "Content-Type: application/json" <<EOF {
"type": "LoginRequest",
"username": "delphix_username",
"password": "delphix_password" } EOF

please help

Upvotes: 0

Views: 406

Answers (1)

Eugene Lebedev
Eugene Lebedev

Reputation: 1474

Just use decomposition for curl commands. For example as we see Authentication requres two steps:

1. create session:

POST request to http://delphix-server/resources/json/delphix/session with JSON-data:

{
    "type": "APISession",
    "version": {
        "type": "APIVersion",
        "major": 1,
        "minor": 1,
        "micro": 0
    }
}

where you specify API version

2. login operation:

POST request to http://delphix-server/resources/json/delphix/login with JSON data:

{
    "type": "LoginRequest",
    "username": "delphix_username",
    "password": "delphix_password"
}

also your client must support cookies (for store auth session)

Upvotes: 1

Related Questions