I'm calling "process.py" 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.

Help!

asked 01 Jun '13, 21:38

frabcus's gravatar image

frabcus
1113

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

(04 Jun '13, 15:05) Anastasia Ga... ♦♦

Python 2.7.1

(05 Jun '13, 12:48) frabcus

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.

(05 Jun '13, 19:23) Anastasia Ga... ♦♦

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: cloud.ocrsdk.com\r\nUser-Agent: Python-urllib/2.7\r\nConnection: close\r\nContent-Type: multipart/form-data; boundary=127.0.0.1.502.6166.NNNNNNNNN.029.1\r\nAuthorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXX==\n\r\n\r\n--127.0.0.1.502.6166.NNNNNNNNN.029.1\r\nContent-Disposition: form-data; name="file"; filename="gr.pdf"\r\nContent-Type: application/pdf\r\n\r\n%PDF-1.4 ...

(05 Jun '13, 20:43) frabcus

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?

(06 Jun '13, 11:34) Dmitry Me ♦♦

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!

(06 Jun '13, 17:07) frabcus

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?

(07 Jun '13, 12:25) Dmitry Me ♦♦
showing 5 of 7 show 2 more comments
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2

Asked: 01 Jun '13, 21:38

Seen: 50,610 times

Last updated: 07 Jun '13, 12:25

Related questions

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal