Reputation: 41
[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:
Get the MediaItemDataRef (This step work without problem):
curl -X POST -v -H "Authorization: Bearer <access_token>"
"https://mybusiness.googleapis.com/v4/accounts//locations//media:startUpload"
I receive a "resourceName" variable.
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"
curl -X POST
--data '{"mediaFormat":"PHOTO","locationAssociation"{"category":"FOOD_AND_DRINK"},"dataRef":
{"resourceName":"<resourceName>"}}'
-H "Authorization: Bearer <access_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.
Upvotes: 3
Views: 973
Reputation: 1
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.
Upvotes: 0