2 Answers
- Newest
- Most votes
- Most comments
2
Document and Textract client not being in the same AWS region is another potential error. Make sure the Textract call is done from the same region as the bucket.
# when your bucket is in us-east-2
textract_client = boto3.client('textract', region_name='us-east-2')
answered 3 years ago
0
I know this is an old post, but it's still relevant. I was getting this error and found that the raw key passed to textract often contained special characters, which were generating this error. To fix this, I decoded the key and then used that when passing data to textract.
Here is an example of what to add, not the entire code
Need to import this to decode the key
import urllib.parse
Then added this code to use the decoded key
decoded_key = urllib.parse.unquote_plus(key)
# Start Textract asynchronous processing, use env vars
response = textract.start_document_text_detection(
DocumentLocation={
'S3Object': {
'Bucket': bucket,
'Name': decoded_key
}
}
answered 6 months ago
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 7 months ago

Hi, thank you for the response. Incredibly, that seems to have worked... Doesn't instantiating both the s3 and textract clients from the same session object ensure they all use the same region?
@danem: The bucket region is defined when the bucket is created, not when the boto3 client session is instantiated. So every S3 bucket is 'bound' to a specific region. Textract on the other hand is available in most regions and when a boto3 client session is instantiated, it will execute the Textract API call against that region.