HTTP Error 400. The request has an invalid header name

  • Last Post 07 June 2013
frabcus posted this 01 June 2013

I'm calling "" from the example Python code, with a very simple example PDF.

I get back "HTTP Error 400. The request has an invalid header name", with no clue as to which header or why.


Order By: Standard | Newest | Votes
Anastasia Galimova posted this 04 June 2013

Could you please clarify, which Python version do you use?

frabcus posted this 05 June 2013

Python 2.7.1

Anastasia Galimova posted this 05 June 2013

Probably the issue occurs because the Python sample was designed for Python version 2.2. To fix the issue the developer asked to find out, what are the headers in the request that you send and what is the server response, using Fiddler or any other HTTP debugger.

frabcus posted this 05 June 2013

Here's the first part of the headers I send outwards, with some auth tokens hidden

POST /processImage?exportFormat=xml&language=Greek HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 385429\r\nHost:\r\nUser-Agent: Python-urllib/2.7\r\nConnection: close\r\nContent-Type: multipart/form-data; boundary=\r\nAuthorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXX==\n\r\n\r\n--\r\nContent-Disposition: form-data; name="file"; filename="gr.pdf"\r\nContent-Type: application/pdf\r\n\r\n%PDF-1.4 ...

Dmitry Me posted this 06 June 2013

This part XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXX==\n\r\n\r\n-- looks quite suspicious - the \n right in the middle and \n\r (instead of \r\n) near the end. Do these really occur in the headers?

frabcus posted this 06 June 2013

Like I said, I hid some auth tokens, as this is a public page! I replaced them with Xs.

If you give me an email or something, I can send you the full headers!

Dmitry Me posted this 07 June 2013

Yes, I understand that you've replaced the actual strings with sequences of X characters, but where do the \n and \n\r sequences come from?