Problems downloading Office365/Exchange calendar using pycurl


I have been using the ews-orgmode / Python script for a couple of months to download my Office365/Outlook/Exchange work calendar without problems. However, last week I rearranged the Python environments on my Linux system (installing fewer packages through the system package manager and more through pip). This stopped my calendar download from working, because I had also uninstalled pycurl (along with some other packages that I had to reinstall using pip in order to make some other scripts run again).

However, also after reinstalling pycurl, I cannot get the script to work anymore. The script and config/settings file have not changed, so either there's something wrong with my Python environment, or between 29-Oct-2019 and 6-Nov-2019 something happened in the server API. I have been trying this normally on my system and in a dedicated virtual environment (installing only the necessary packages), but to no avail, and I'm at a loss as to what to do next, hence my post here.

The script is written in Python2, and I have Python2.7 installed on my Gentoo Linux system. The issue seems to be an error reported by the Outlook/EWS server which results in an empty response which finally breaks down the code. I strongly suspect that the problem lies in the pycurl/server interaction, but I am not suffucienctly knowedgable to find out what the exact problem is. Any hints (or solutions) would be welcome :-)

  ewsUrl EWS/Exchange.asmx
  ewsUser xxx@xxx.xx
  ewsPassword xxxxxxxxxxxx
  ewsAuthType basic
  timezoneLocation xxx/xxx
  daysHistory 30
  daysFuture 90
  maxEntries 300

Debug output pycurl:
  *   Trying
  * Connected to ( port 443 (#0)
  * ALPN, offering http/1.1
  * successfully set certificate verify locations:
  *   CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: /etc/ssl/certs
  * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
  * ALPN, server did not agree to a protocol
  * Server certificate:
  *  subject: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation;
  *  start date: Nov 17 00:00:00 2018 GMT
  *  expire date: Nov 17 12:00:00 2020 GMT
  *  subjectAltName: host "" matched cert's "*"
  *  issuer: C=US; O=DigiCert Inc; CN=DigiCert Cloud Services CA-1
  *  SSL certificate verify ok.
  * Server auth using Basic with user 'xxx@xxx.xx'
  > POST /EWS/Exchange.asmx HTTP/1.1
  Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxx
  User-Agent: PycURL/ libcurl/7.66.0 OpenSSL/1.1.1d zlib/1.2.11 libssh2/1.9.0
  Accept: */*
  Transfer-Encoding: chunked
  Content-Type: text/xml; charset=UTF-8
  Content-Length: 912
  Expect: 100-continue

  * Mark bundle as not supporting multiuse
  < HTTP/1.1 500 Internal Server Error
  < Server: Microsoft-IIS/10.0
  < request-id: ec37d426-3b42-4c40-9136-9f085e39e833
  < X-CalculatedFETarget:
  < X-ProxyErrorLabel: ProxyHandler::ExecuteRequestHandler/ProxyHandler::SubmitBackEndRequest
  < X-ProxyErrorHResult: 0x80070057
  < X-ProxyErrorMessage: The parameter is incorrect.
  < X-Proxy-RoutingCorrectness: 1
  < X-Powered-By: ASP.NET
  < X-FEServer: AM4PR0501CA0059
  < Date: Thu, 07 Nov 2019 10:37:51 GMT
  < Content-Length: 0
  * HTTP error before end of send, stop sending
  * Closing connection 0

  Traceback (most recent call last):
    File "./", line 204, in <module>
      root = etree.fromstring(data)
    File "src/lxml/etree.pyx", line 3234, in lxml.etree.fromstring
    File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
    File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDoc
    File "src/lxml/parser.pxi", line 1127, in lxml.etree._BaseParser._parseDoc
    File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc
    File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
    File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
    File "<string>", line 1
  lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
asked on Stack Overflow May 26, 2020 by AstroFloyd

1 Answer


I never got ews-orgmode to work again, and I never understood why.

Meanwhile, I have started using Exchangelib, which I now use to sync my Office365 calendar to my local Orgmode Agenda (one-way traffic), inspired by this answer.

answered on Stack Overflow May 26, 2020 by AstroFloyd

User contributions licensed under CC BY-SA 3.0