On Sun, Jun 1, 2014 at 10:51 PM, dimas yoga pratama <smid...@gmail.com>
wrote:

> Hi All,
>
> I'm doing an experiment on using Cloudstack API.
> From what I read here
> http://cloudstack.apache.org/docs/api/apidocs-4.3/user/login.html when the
> login succeeds,it will generate cookie JSESSIONID.
> My question is, when I create login page, and succsfull login will redirect
> to another page, do I have to pass JSESSIONID to another page like
> SESSIONKEY?
>


Here's an example with curl.

Remember that parameters has to be encoded if they contain any kind of
special characters.

Login:
curl -i '
http://localhost:8080/client/api?command=login&user=admin&password=MyPassword&response=json
'
returns a snippet like this:

Set-Cookie: JSESSIONID=07CA185081E6A476775ECA9D190EF1F8; Path=/client

{ "loginresponse" : { "timeout" : "1800", "lastname" : "cloud",
"registered" : "false", "username" : "admin", "firstname" : "admin",
"domainid" : "6f920fbd-94fc-11e3-b2e0-0050568c15a3", "type" : "1", "userid"
: "d68e7072-94fc-11e3-b2e0-0050568c15a3", "sessionkey" :
"WxjAu9zZzbmrBGDarnW1cVfm+/g=", "account" : "admin" } }


Then you take the JSESSIONID and sessionkey and pass them as Ove said.

List Zones example using above

curl -i -H "Cookie: JSESSIONID=07CA185081E6A476775ECA9D190EF1F8;
Path=/client" '
http://localhost:8008/client/api?command=listZones&sessionkey=WxjAu9zZzbmrBGDarnW1cVfm%2B%2Fg%3D&response=json
'


-- 

Erik Weber

Reply via email to