Zimbra-Community / python-zimbra

Core framework for easily sending requests to the Zimbra SOAP-API
BSD 2-Clause "Simplified" License
63 stars 26 forks source link

Wrong request data object created? #22

Closed spaceone closed 7 years ago

spaceone commented 7 years ago

I have the following data structure:

method = 'CheckAuthConfigRequest'
data = {'attributes': [{'_content': 'ldap', 'n': 'zimbraAuthMech'}, {'_content': 'ldap://master.zimbra-workshop.intranet:7389', 'n': 'zimbraAuthLdapURL'}, {'_content': 'dc=zimbra-workshop,dc=intranet', 'n': 'zimbraAuthLdapSearchBase'}, {'_content': 'uid=zimbra4ucs,cn=users,dc=zimbra-workshop,dc=intranet', 'n': 'zimbraAuthLdapSearchBindDn'}, {'_content': 'QmSPv8RQBs5IPXIUSyrG', 'n': 'zimbraAuthLdapSearchBindPassword'}, {'_content': '(&(uid=%n)(objectClass=person))', 'n': 'zimbraAuthLdapSearchFilter'}], 'password': '', 'name': 'example2.com'}

The internal encoder transform it into the following JSON, before the request is send to the zimbra server:

{"Body": {"CheckAuthConfigRequest": {"attributes": [{"_content": "ldap", "n": "zimbraAuthMech"}, {"_content": "ldap://master.zimbra-workshop.intranet:7389", "n": "zimbraAuthLdapURL"}, {"_content": "dc=zimbra-workshop,dc=intranet", "n": "zimbraAuthLdapSearchBase"}, {"_content": "uid=zimbra4ucs,cn=users,dc=zimbra-workshop,dc=intranet", "n": "zimbraAuthLdapSearchBindDn"}, {"_content": "QmSPv8RQBs5IPXIUSyrG", "n": "zimbraAuthLdapSearchBindPassword"}, {"_content": "(&(uid=%n)(objectClass=person))", "n": "zimbraAuthLdapSearchFilter"}], "_jsns": "urn:zimbraAdmin", "password": "", "name": "example2.com"}}, "Header": {"context": {"authToken": {"_content": {"_content": "0_4a0a538e79c9920b114e6bc3614c71dc213a18eb_69643d33363a30646137356434302d633134392d343465322d626536302d3637643333353835323830653b6578703d31333a313438343237303532363034383b61646d696e3d313a313b747970653d363a7a696d6272613b753d313a613b7469643d393a3730333030383130383b76657273696f6e3d31333a382e372e315f47415f313637303b"}}, "_jsns": "urn:zimbra", "format": {"type": "js"}}}}

But the server responds with: Response failed: invalid request: must specifiy: zimbraAuthMech (code: service.INVALID_REQUEST)

But it is obvious that zimbraAuthMech is set as attribute. See also https://files.zimbra.com/docs/soap_api/8.7.0/api-reference/zimbraAdmin/CheckAuthConfig.html

dploeger commented 7 years ago

I think, you shouldn't use the key "attributes", but rather "a" like the xml tag names in the documentation.

spaceone commented 7 years ago

Ah thank you very much :) !