Dear all,

I was looking at handling of case in API calls and I believe the docs
page has a slight mistake in the code example:

http://docs.cloudstack.apache.org/en/latest/dev.html#the-cloudstack-api

The signature generation instructions say:
  "Lower case the entire Command String and sort it alphabetically"

however the sample code does this:

 
sig_str='&'.join(['='.join([k.lower(),urllib.quote_plus(request[k].lower().replace('+','%20'))])for
k in sorted(request.iterkeys())])

which I think is the other way around (sort then lowercase).

This will cause a problem if I send an API request of the form:
 apiKey=........&Command=listZones&.....

Putting the capital C on Command is an odd thing to do but it should
be allowed because the parameter 'field' is not case sensitive,
according to the docs page.

Now because the 'sort first' will put 'Command=...' before
'apiKey=...' this will give a different signature, compared with
'lowercase first'.

So then I started to run some tests against my CloudStack API server
and actually I am finding that API calls *do* fail if I change the
case of the parameter fields. For example, if I do

cOMMAND=listZones

This does not change parameter order or the signature value, but the
API call fails with error 401 "unable to verify user credentials
and/or request signature".

Has anyone else seen this kind of behaviour?

Thx Phillip

Reply via email to