You can use the following two methods to upload media to the Google My Business API:
Upload from a URL
To upload photos to the Google My Business API using a URL, making the following call to
Media.Create
. Use the relevant category as needed.
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/media { "mediaFormat": "PHOTO", "locationAssociation": { "category": "COVER" }, "sourceUrl": “http://example.com/biz/image.jpg", }
To use a URL to upload videos, make the following call to
Media.Create
:
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/media { "mediaFormat": "VIDEO", "locationAssociation": { "category": "ADDITIONAL" }, "sourceUrl": “http://example.com/biz/video.mp4", }
Upload from bytes
Use the following steps to upload media to the Google My Business API from bytes:
To begin the upload, make the following call:
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/media:startUpload
The response from the API returns a body that contains a
MediaItemDataRef
:{ "resourceName": "GoogleProvidedValue", }
Use the
resourceName
returned by the call made in the previous step to upload the bytes. The following is an example where the media to be uploaded is a photo:curl -X POST -T ~/Downloads/pictureToUpload.jpg "https://mybusiness.googleapis.com/upload/v1/media/{GoogleProvidedValue}?upload_type=media"
Following is an example if the media is a video:
curl -X POST -T ~/Downloads/videoToUpload.mp4 "https://mybusiness.googleapis.com/upload/v1/media/{GoogleProvidedValue}?upload_type=media"
Call
Media.Create
using theresourceName
returned in Step 1. Use the relevant mediaFormat and categoryPOST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/media { "mediaFormat": "PHOTO", "locationAssociation": { "category": "COVER" }, "dataRef": { "resourceName": "GoogleProvidedValue" }, }
POST https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/media { "mediaFormat": "VIDEO", "locationAssociation": { "category": "ADDITIONAL" }, "dataRef": { "resourceName": "GoogleProvidedValue" }, }