ChumiestBucket
ChumiestBucket

Reputation: 1066

"requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: ..." when trying to create CloudOCR object

Let me first say that I'm not sure if I'm using this library properly.

Method #1

I'm going off of this page (here's the Github). I'm using this code:

from ABBYY import CloudOCR

ocr = CloudOCR(application_id='ApplicationID', password='SuperSecretPasswordFromAbbyy')
pdf = open('blah.pdf', 'rb')
file = {pdf.name: pdf}

result = ocr.process_and_download(
  file,
  exportFormat='xml,pdfTextAndImages',
  language='English'
)

print(result)

Here's the error I get:

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://cloud.ocrsdk.com/processImage?exportFormat=xml%2CpdfTextAndImages&language=English

If I follow the link inside the error traceback I see the following text:

404 HTTP method GET not supported for /processImage, only method POST supported

Method #2

I'm trying to send a local PDF to the Cloud OCR platform. I've had success using the package found here like so:

$ export ABBYY_APPID='ApplicationID'
$ export ABBYY_PWD='SuperSecretPasswordFromAbbyy'
...
$ python process.py -pdf blah.pdf result.txt

I want to implement a system using Method #1. I'm just wondering what to do differently to make that happen. The fact that Method #2 works shows that authentication isn't an issue.

Upvotes: 4

Views: 11867

Answers (1)

Ravi Sharma
Ravi Sharma

Reputation: 60

State: -- I have also encountered the same problem, using both the methods.

Solution -- In case of your correct Application_ID and Password, you are still getting the same error, the reason is your UK or US registration selection at the registration-form.

Both US and UK have different ServerUrl:

  1. http://cloud-westus.ocrsdk.com if you created your application in US location
  2. http://cloud-eu.ocrsdk.com if you created your application in UK location

changed ServerUrl in AbbyyOnlineSdk.py according to location.

Mission passed for me!

Hope this help.

Upvotes: 0

Related Questions