views:

44

answers:

2

Hi,

I need to retrieve a document with MIME type "application/json". I'm using twill to log in to a site and when I attempt to go to the URL pointing to the JSON document and show it, I get this message:

'The HTTP header field "Accept" with value "text/html; */*" could not be parsed.'

I have tried changing the "Accept" field to "application/json" but still no dice.

Thanks!!

A: 

This is by no means the answer I'm looking for, but zope.testbrowser will do what I want.

The interface is slightly more complicated than twill, but not by much.

Still looking for a twill solution!

Tyler
A: 

Looks like you have Accept: text/html; */* which seems syntactically wrong to me: per w3.org, the syntax is

    <field>  =    Accept: <entry> *[ , <entry> ]
    <entry>  =    <content type> *[ ; <param> ]
    <param>  =    <attr> = <float>
    <attr>   =    q / mxs / mxb
    <float>  =    <ANSI-C floating point text represntation>

so that */*, since it follows a semicolon rather than a comma, should be a <param>, but not in fact of the form <attr> = <float>. Did you mean to have a q=something, after the semicolon, and forgot to give it? Else, just text/html, */* -- i.e., with a comma, not a semicolon -- seems to be the right syntax.

Alex Martelli
Thanks, I'll look in to this.
Tyler