I have a web service that returns JSON responses when successful. Unfortunately, when I try to test this service via multi-mechanize, I get an error – “not viewing HTML”. Obviously it’s not viewing HTML, it’s getting content clearly marked as JSON. How do I get mechanize to ignore this error and accept the JSON it’s getitng back?
I have a web service that returns JSON responses when successful. Unfortunately, when I
Share
It turns out mechanize isn’t set up to accept JSON responses out of the box. For a quick and dirty solution to this, update mechanize’s _headersutil.py file (check /usr/local/lib/python2.7/dist-packages/mechanize).
In the is_html() method, change the line:
to read: