Error 1000 Fetching image failed. I can't upload a binary photo using the google business API

870 Views Asked by At

[API google GMB] Can not upload a photo using the media.upload API for Upload from bytes.

Hi I am trying to upload a photo from bytes using the google my business API following the steps describe in the next guide: guide upload from bytes.

For test I am using curl requests.

the step are:

  1. Get the MediaItemDataRef (This step work without problem):

    curl -X POST -v -H "Authorization: Bearer <acce​ss_token>"
    "https://mybusiness.googleapis.com/v4/accounts//locations//media:startUpload"

    I receive a "resourceName" variable.

  2. Use the resourceName returned by the call made in the previous step to upload the bytes:

   curl -X POST -T ~/<patch_to_the_file.png> -v -H "Authorization:
   Bearer <access_token>"
   "https://mybusiness.googleapis.com/upload/v1/media/<resourceName>?uploadType=media"
  1. Call Media.Create using the resourceName returned in Step 1:
    curl -X POST 
    --data '{"mediaFormat":"PHOTO","locationAssociation"{"category":"FOOD_AND_DRINK"},"dataRef": 
    {"resourceName":"<resourceName>"}}' 
    -H "Authorization: Bearer <acce​ss_token>
    -H "Content-Type: application/json" 
    "https://mybusiness.googleapis.com/v4/accounts/<id_account>/locations/<id_
    locations>/media"

In the 3 step I receive the following error in the answers:

 {  
    "error": {
       "code": 400,
       "message": "Request contains an invalid argument.",
       "status": "INVALID_ARGUMENT",
       "details": [
         {
           "@type": "type.googleapis.com/google.mybusiness.v4.ValidationError",
           "errorDetails": [
             {
               "code": 1000,
               "message": "Fetching image failed."
             }
           ]
         }
       ]   
     } 
  }

I had to try the same steps in Python and I have the same error, so I want to know what my error is in the request.

Thank you.

1

There are 1 best solutions below

0
On

I had a similar phenomenon. And I was able to solve the problem. In my case, the posting cycle for the same store was about 18 seconds, but when I corrected it to a 60-second cycle, it was resolved.