Search code examples
ocrgcloudgoogle-cloud-visiongoogle-vision

Google Cloud Vision API 'Request Admission Denied'


I am new to Google Cloud Vision API. I am doing OCR on images primarily for bills and receipts.

For a few images it is working fine, but when I try some other images it gives me this error:

Error:  { [Error: Request Admission Denied.]
  code: 400,
  errors:
   [ { message: 'Request Admission Denied.',
       domain: 'global',
       reason: 'badRequest' } ] }

This is my code:

// construct parameters
const req = new vision.Request({
image: new vision.Image('./uploads/reciept.png'),
features: [
new vision.Feature('TEXT_DETECTION', 1)
]
})

vision.annotate(req).then((res) => {
// handling response
//console.log(res.responses[0].textAnnotations);
var desc=res.responses[0].textAnnotations;
var descarr=[];
for (i = 0; i < desc.length; i++) { 
descarr.push(desc[i].description);
}

Solution

  • Ran into this problem as well. It was an image size issue. I don't know what the hard limit is. 4MB worked, but 9MB didn't, it's somewhere in between there.