It worked. Thanks Rohit.
On Mon, Oct 27, 2014 at 11:32 PM, Rohit Yadav <rohit.ya...@shapeblue.com> wrote: > Hi Meghna, > > The timezone [2] that you provide to this python script already URL > encodes the string in the param dictionary [1]. So, if you give it a > timezone with a “/“ character, for example in case of “Asia/Kolkata” if you > give it “Asia%2FKolkata” then the URL encoded value is “Asia%252FSeoul”. > > The CloudStack ApiServer URL decode parameters received in an API request > [1] so the timezone string becomes “Asia%2FSeoul” on decoding, therefore it > is stored with the %2F string in DB and not “/“. So, please don’t double > URL encode. > > I tried the following for myself against 4.3.1 and it works for me; > cloudmonkey update user id=<my-user-uuid> timezone=Asia/Kolkata > > [1] http://cloudstack.apache.org/docs/api/apidocs-4.3/user/updateUser.html > [2] http://docs.cloudstack.apache.org/en/latest/dev.html#time-zones > > > On 27-Oct-2014, at 10:54 pm, Meghna Kale <meghna.k...@sungardas.com> > wrote: > > > > Thanks Rohit for the reply. > > Python script - > > I just found it on internet. > > request_type = 'GET' > > params = { > > 'command':'updateUser', > > 'id':user_id > > } > > if email: params['email'] = email > > if first_name: params['firstname'] = first_name > > if last_name: params['lastname'] = last_name > > if password: params['password'] = password > > if timezone: params['timezone'] = timezone > > if user_name: params['username'] = user_name > > > > params['response'] = 'json' > > params['apiKey'] = self.api_key > > > > # build the query string > > query_params = map(lambda (k,v):k+"="+urllib.quote(str(v)), > > params.items()) > > query_string = "&".join(query_params) > > > > # build signature > > query_params.sort() > > signature_string = "&".join(query_params).lower() > > signature = > > urllib.quote(base64.b64encode(hmac.new(self.secret_key, signature_string, > > hashlib.sha1).digest())) > > > > # final query string... > > url = > > > self.protocol+"://"+self.host+self.uri+"?"+query_string+"&signature="+signature > > print url > > output = None > > try: > > output = json.loads(urllib2.urlopen(url).read()) > > Thanks > > Meghna. > > > > On Mon, Oct 27, 2014 at 4:02 PM, Rohit Yadav <rohit.ya...@shapeblue.com> > > wrote: > > > >> Hi, > >> > >>> On 27-Oct-2014, at 2:58 pm, Meghna Kale <meghna.k...@sungardas.com> > >> wrote: > >>> > >>> I'm was trying to call Cloudstack create/update user API from a python > >>> script. > >> > >> Can you share the python script? Perhaps it was assume some data? > >> > >>> But when I add or update timezone it fails with 401 error code. I > >> debugged > >>> and found that timezone has a special character '/'. I replaced it with > >>> '%2F', the API call returns success but it updates the timezone with > the > >>> '%2F' string in DB. > >> > >> Url encode when you make API requests. The default timezone is GMT, > unless > >> you’ve passed timezone arg. > >> > >> Regards, > >> Rohit Yadav > >> Software Architect, ShapeBlue > >> M. +91 88 262 30892 | rohit.ya...@shapeblue.com > >> Blog: bhaisaab.org | Twitter: @_bhaisaab > >> > >> > >> > >> Find out more about ShapeBlue and our range of CloudStack related > services > >> > >> IaaS Cloud Design & Build< > >> http://shapeblue.com/iaas-cloud-design-and-build//> > >> CSForge – rapid IaaS deployment framework<http://shapeblue.com/csforge/ > > > >> CloudStack Consulting<http://shapeblue.com/cloudstack-consultancy/> > >> CloudStack Infrastructure Support< > >> http://shapeblue.com/cloudstack-infrastructure-support/> > >> CloudStack Bootcamp Training Courses< > >> http://shapeblue.com/cloudstack-training/> > >> > >> This email and any attachments to it may be confidential and are > intended > >> solely for the use of the individual to whom it is addressed. Any views > or > >> opinions expressed are solely those of the author and do not necessarily > >> represent those of Shape Blue Ltd or related companies. If you are not > the > >> intended recipient of this email, you must neither take any action based > >> upon its contents, nor copy or show it to anyone. Please contact the > sender > >> if you believe you have received this email in error. Shape Blue Ltd is > a > >> company incorporated in England & Wales. ShapeBlue Services India LLP > is a > >> company incorporated in India and is operated under license from Shape > Blue > >> Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in > Brasil > >> and is operated under license from Shape Blue Ltd. ShapeBlue SA Pty Ltd > is > >> a company registered by The Republic of South Africa and is traded under > >> license from Shape Blue Ltd. ShapeBlue is a registered trademark. > >> > > Regards, > Rohit Yadav > Software Architect, ShapeBlue > M. +91 88 262 30892 | rohit.ya...@shapeblue.com > Blog: bhaisaab.org | Twitter: @_bhaisaab > > > > Find out more about ShapeBlue and our range of CloudStack related services > > IaaS Cloud Design & Build< > http://shapeblue.com/iaas-cloud-design-and-build//> > CSForge – rapid IaaS deployment framework<http://shapeblue.com/csforge/> > CloudStack Consulting<http://shapeblue.com/cloudstack-consultancy/> > CloudStack Infrastructure Support< > http://shapeblue.com/cloudstack-infrastructure-support/> > CloudStack Bootcamp Training Courses< > http://shapeblue.com/cloudstack-training/> > > This email and any attachments to it may be confidential and are intended > solely for the use of the individual to whom it is addressed. Any views or > opinions expressed are solely those of the author and do not necessarily > represent those of Shape Blue Ltd or related companies. If you are not the > intended recipient of this email, you must neither take any action based > upon its contents, nor copy or show it to anyone. Please contact the sender > if you believe you have received this email in error. Shape Blue Ltd is a > company incorporated in England & Wales. ShapeBlue Services India LLP is a > company incorporated in India and is operated under license from Shape Blue > Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in Brasil > and is operated under license from Shape Blue Ltd. ShapeBlue SA Pty Ltd is > a company registered by The Republic of South Africa and is traded under > license from Shape Blue Ltd. ShapeBlue is a registered trademark. >