how we do post in maas-api (1.8.2)

Asked by Binoy M V

How to do post in maas-api with version 1.8.2
Get is working fine. When i try to get the details from the api, it got success. But in case of user and other post it is notworking.

I tried with SSh key it seems working with the following code

sshKeys = {"key": [keyValue]}
#Creating the sshkey
maas_access.post(u"account/prefs/sshkeys/", "new", **sshKeys)

But in case of user, zones etc seems not working.

from apiclient import maas_client
maas_access = maas_client.MAASClient(maas_client.MAASOAuth(*APIKEY.split(":")), maas_client.MAASDispatcher(), MAAS_URL)
keyAndData = {"name": "defaulttest", "description": "test"}
maas_access.post(u"zones/", 'new', **keyAndData)

File "/usr/lib/python2.7/dist-packages/apiclient/maas_client.py", line 250, in post
    url, method="POST", headers=headers, data=body)
  File "/usr/lib/python2.7/dist-packages/apiclient/maas_client.py", line 116, in dispatch_query
    res = urllib2.urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 539, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: BAD REQUEST

I don't know what i am doing wrong. Please help me on this.

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu maas Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.