i need help with may code request send 400 bad request

APPID = "*" APPPASSWORD = "***" URL = "https://cloud.ocrsdk.com/processImage"

def send(): to_encode = APPID + ":" + APPPASSWORD iso_encoding = to_encode.encode("iso-8859-1") base = base64.b64decode(iso_encoding)

base_header = {"Authorization": "Basic " + base}

r = requests.post(URL, files={'photo.jpg': open('photo.jpg', 'rb')},
                  json=json.dumps({"language": "Hebrew", "textType": "normal", "exportFormat": "txt"}),
                  headers=base_header)

response_xml = r.content

print response_xml

return "ok"

asked 24 Dec '15, 17:16

easy-send's gravatar image

easy-send
111


Hi,

In this case you actually want to get a base64-encoded string, so please replace this line

base = base64.b64decode(iso_encoding)

with the following one:

base = base64.b64encode(iso_encoding)
link

answered 28 Dec '15, 17:53

IvanPopov's gravatar image

IvanPopov ♦♦
363

Your answer
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:

×9

Asked: 24 Dec '15, 17:16

Seen: 415 times

Last updated: 28 Dec '15, 17:53

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