Attach Media
This guide describes how to upload and attach media (videos and images) using the REST API. It is critical that your uploaded media is in a READY state before it can be successfully included in your post to the specified Social Network.
Step 1: Request a Media URL
Use the API to generate an expiring upload URL for media, and specify the exact size. This endpoint will also return an identifier we can use when scheduling a message with this media. See Authentication on how to obtain the appropriate access token.
curl -X POST -H "Authorization: Bearer [USER_ACCESS_TOKEN]" \
-d '{"sizeBytes":8036821, "mimeType": "video/mp4"}' \
https://platform.hootsuite.com/v1/media
{
"data": {
"uploadUrl": "https://hootsuite-video.s3.amazonaws.com/production/3563111_6923ef29-d2bd-4b2a-a6d2-11295411c988.mp4?AWSAccessKeyId=AKIAIHSDDN2I7V2FDJGA&Expires=1465846288&Signature=3xLFijSn02YIx6AOOjmri5Djkko%3D",
"uploadUrlDurationSeconds": 599,
"id": "aHR0cHM6Ly9ob290c3VpdGUtdmlkZW8uczMuYW1hem9uYXdzLmNvbS9wcm9kdWN0aW9uLzM1NjMxMTFfNjkyM2VmMjktZDJiZC00YjJhLWE2ZDItMTEyOTU0MTFjOTg4Lm1wNA=="
}
}
Breakdown of the response
uploadUrl: The url you will upload your media to
uploadUrlDurationSeconds: The number of seconds until your upload url expires
id: The identifier for your media. This identifier is what you will use when scheduling your media or retrieving the media object
Step 2: Upload your media
Upload your media directly into our s3 bucket
curl -X PUT -H 'Content-Type: video/mp4' \
-H "Content-Length: 8036821" \
-T "/Users/kenh/Downloads/amazing_race.mp4" \
"https://hootsuite-video.s3.amazonaws.com/production/3563111_6923ef29-d2bd-4b2a-a6d2-11295411c988.mp4?AWSAccessKeyId=AKIAIHSDDN2I7V2FDJGA&Expires=1465846288&Signature=3xLFijSn02YIx6AOOjmri5Djkko%3D"
Amazon will return a 200 OK if the upload was successful. The content-length header must match exactly the size you specified when requesting the upload url.
Step 3: Schedule your message
Schedule the message as normal. Note that if your media type is a video, you must schedule it at least 15 minutes into the future. For larger video sizes, we recommend scheduling an hour into the future, especially if you are using an Approval process. Alternatively, you can send a message without a fixed send time and it will automatically be assigned the soonest possible send time. Refer to Event Reference for a list and description of message states.
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer [USER_ACCESS_TOKEN]" \
-d '{"text":"Testing videos.", "scheduledSendTime":"2017-08-24T00:00:00Z","socialProfileIds":[150326369],"media": [{"id": "aHR0cHM6Ly9ob290c3VpdGUtdmlkZW8uczMuYW1hem9uYXdzLmNvbS9wcm9kdWN0aW9uLzM1NjMxMTFfNjkyM2VmMjktZDJiZC00YjJhLWE2ZDItMTEyOTU0MTFjOTg4Lm1wNA==","videoOptions":{"facebook":{"title":"This is a title", "category": "ENTERTAINMENT"}}}]}' \
https://platform.hootsuite.com/v1/messages
{
"data": [
{
"id": "3869800103",
"state": "SCHEDULED",
"text": "Testing videos.",
"scheduledSendTime": "2017-08-24T00:00:00Z",
"socialProfile": {
"id": "150326369"
},
"media": [
{
"id":"aHR0cHM6Ly9ob290c3VpdGUtdmlkZW8uczMuYW1hem9uYXdzLmNvbS9wcm9kdWN0aW9uLzM1NjMxMTFfNjkyM2VmMjktZDJiZC00YjJhLWE2ZDItMTEyOTU0MTFjOTg4Lm1wNA==",
"thumbnailId":"aHR0cHM6Ly9ob290c3VpdGUtdmlkZW8uczMuYW1hem9uYXdzLmNvbS9wcm9kdWN0aW9uLzM1NjMxMTFfNjkyM2VmMjktZDJiZC00YjJhLWE2ZDItMTEyOTU0MTFjOTg4LTAwMDEubXA0",
"videoOptions":{"facebook":{"title":"This is a title", "category": "ENTERTAINMENT"}}
}
],
"webhookUrls": null,
"tags": null,
"targeting": null,
"privacy": null,
"location": null,
"emailNotification": null,
"postUrl": null,
"postId": null
}
]
}
Note: Specifying a custom thumbnail is not yet supported. A thumbnail will be auto generated for the uploaded media.
Attaching video with the iFrame SDK
If you're building a content source component with the iFrame SDK and want to attach videos to posts within the Hootsuite dashboard, you must leverage the REST API.
After completing Steps 1 and 2 of this guide, you can pass the id returned by the REST API media endpoint to the hsp.attachMediaV2 method as its mediaId parameter.
Valid Media Types
These are the types of media that are currently accepted:
| MimeType |
|---|
| video: mp4, mov image: gif, jpeg, jpg, png |
Media Restrictions
Please refer to the following for image and video file requirements:
Hootsuite Image File Requirements
Hootsuite Video File Requirements
Troubleshooting
- When you try to upload media to s3, if you are receiving:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<AWSAccessKeyId>AKIAIM7ASX2JTE3ZFAAA</AWSAccessKeyId>
<StringToSign>PUT
video/mp4
1469060596
/hootsuite-video/production/12255244_24f18e82-85d6-4d12-9297-00648bccdd1a.mp4</StringToSign>
<SignatureProvided>LZH4SQKaL3vNjS2Gh4lI06owpa0="</SignatureProvided>
<StringToSignBytes>50 55 54 0a 0a 76 69 64 65 6f 2f 6d 70 34 0a 31 34 36 39 30 36 30 35 39 36 0a 2f 68 6f 6f 74 73 75 69 74 65 2d 76 69 64 65 6f 2f 70 72 6f 64 75 63 74 69 6f 6e 2f 31 32 32 35 35 32 34 34 5f 32 34 66 31 38 65 38 32 2d 38 35 64 36 2d 34 64 31 32 2d 39 32 39 37 2d 30 30 36 34 38 62 63 63 64 64 31 61 2e 6d 70 34</StringToSignBytes>
<RequestId>152E48C7DA00B50F</RequestId>
<HostId>7Nm4YQv1GF5Xwf572sFUZLBLSyAF8ldHXysUFSyLRNWoImS9gsPQgqASTRitb38xH1691KpLCj4=</HostId>
</Error>
This could be caused by any of the following reasons:
Missing header
Verify that both the Content-type and Content-length headers are sent with the request.
File missing
Verify that the file is sent with the request.
Content length does not match policy
The content length header value must be the same as the size of the file and the sizeBytes passed in when requesting an upload URL using the Media API.
Signature missing
Verify that the signature query parameters are sent with the request.
Signature expired
The signature might be expired. In this request a new upload URL from the Media API and use that to upload your file to s3.