1

I'm trying to use the Zimbra SOAP API from Python to programmatically modify & cleanup my contacts but I'm having trouble getting started.

What I have so far is:

from SOAPpy import SOAPProxy
url = 'https://zimbra/service/soap'
auth = {"account": "xxxxx", "password": "xxxxx"}

zimbra = SOAPProxy(url, 'urn:zimbra')
zimbraAuth = SOAPProxy(url, "urn:zimbraAccount")
zimbraMail = SOAPProxy(url, "urn:zimbraMail")

response = zimbraAuth.AuthRequest(**auth)
authToken = response.authToken 

I've logged in successfully, but can't pass this authToken in further requests.

My understanding is that any zimbraMail requests need to have a header in the urn:zimbra namespace with the authToken set there, but being new to SOAP I have no idea how to do so.

I'm not married to using SOAPpy so any example code for another library would be well appreciated.

MikeyB
  • 3,288
  • 1
  • 27
  • 38
  • 1
    Just wanted to mention that SOAPpy hasn't been maintained since 2005. ZSI had most of, if not all of, the features of SOAPpy merged into it and is now the single Python Web Services Project toolkit. http://pywebsvcs.sourceforge.net/ – sberry Feb 08 '10 at 16:19
  • Good to know, thanks! Via other questions here, I'm now looking at SUDS. – MikeyB Feb 08 '10 at 17:01

2 Answers2

1

I'd like to nod in the direction of Python-Zimbra, a python library for Zimbra, which does all that for you.

1

There is also an higher level, and pythonic library: zimsoap.

Using raw SOAP or python-zimbra or zimsoap depends realy on what level of flexibility/ease you need (although I will not suggest using SOAP directly, as python-zimbra can issue any possible SOAP request to zimbra.

Jocelyn delalande
  • 5,123
  • 3
  • 30
  • 34