Upload media

You can use the Google My Business API to upload media with the following two methods:

Upload from a URL

To upload photos from a URL , make 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 upload videos from a URL with the Google My Business API, 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

To upload media from bytes with the Google My Business API, complete the following steps:

  1. 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",
      }
  2. To upload the bytes, use the resourceName returned by the call made in the previous step. 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"

    The 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"
  3. Use the resourceName returned in Step 1 to call Media.Create. Use the relevant mediaFormat and category.

      POST 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"
        },
      }