Python - Sending an argument as a struct -
i working api requires me give 3 arguments.
string sessionkey int serverid struct date details datetime.iso8601 startdate - optional, unless enddate provided. datetime.iso8601 enddate - optional.
i not sure how define struct in this case. calling api way.
>>> server.system.provisioning.snapshot.listsnapshots(sessionkey,1000078204, {datetime.now() , datetime.now()})
so im defining struct
syntax:
{datetime.now() , datetime.now()}
this gives me error:
traceback (most recent call last): file "/usr/lib64/python3.4/xmlrpc/client.py", line 512, in __dump f = self.dispatch[type(value)] keyerror: <class 'set'> during handling of above exception, exception occurred: traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib64/python3.4/xmlrpc/client.py", line 1098, in __call__ return self.__send(self.__name, args) file "/usr/lib64/python3.4/xmlrpc/client.py", line 1431, in __request allow_none=self.__allow_none).encode(self.__encoding) file "/usr/lib64/python3.4/xmlrpc/client.py", line 951, in dumps data = m.dumps(params) file "/usr/lib64/python3.4/xmlrpc/client.py", line 504, in dumps dump(v, write) file "/usr/lib64/python3.4/xmlrpc/client.py", line 516, in __dump raise typeerror("cannot marshal %s objects" % type(value)) typeerror: cannot marshal <class 'set'> objects
am defining struct
wrong ?
in xml-rpc (which error traceback indicates you're using), "struct" python calls "dict(ionary)", you're trying use set
instead. need create dict
using key names given in api documentation (i.e., startdate
, enddate
), thus:
>>> server.system.provisioning.snapshot.listsnapshots(sessionkey,1000078204, {"startdate": datetime.now(), "enddate": datetime.now()})
Comments
Post a Comment