Getting "media parameter is invalid" after successfully uploading media

media-upload

#1

Hi,
We’ve been getting several errors after posting status updates with media attached.

It seems the error occurs for images that are larger than 3Mb (the limit reported by /help/configuration.json), despite the fact that the image uploads successfully:

  1. Upload an image:

$ twurl -H upload.twitter.com -X POST “/1.1/media/upload.json” --file “image.jpg” --base64 --file-field “media_data”
{“media_id”:677947581679296512,“media_id_string”:“677947581679296512”,“size”:3147175,“expires_after_secs”:86400,“image”:{“image_type”:“image/jpeg”,“w”:2448,“h”:2561}}

  1. Post a tweet with the media attached:

$ twurl -X POST “/1.1/statuses/update.json?status=blarg&media_ids=677947581679296512”
{“errors”:[{“code”:44,“message”:“media parameter is invalid.”}]}

Can someone provide insight into what caused this error?

If this error is truly caused by the image being too large, shouldn’t it be reported during the post to /1.1/media/upload.json?

Thanks for any information you can provide, this one has been truly difficult to debug on our side :smile:


#2

Also wanted to note that the official API docs say the limit is 5MB, which we assumed was correct until Brian thought to check the configuration.json endpoint :grimacing:
so if the limit is really 3MB, then part of the problem is incorrect documentation.


#3

Got a reply privately:

The media/upload endpoint’s upload limit, which is used for Tweet
photos, profile photos, etc, is indeed 5MB. However, a photo that is
attached to a Tweet cannot be larger than 3MB.
That’s why you get a successful upload response, but a failed Tweet attempt, for anything between 3MB and 5MB.


#4

Ah, that explains it - but that should definitely be explained in the documentation. The docs don’t need to mention specific limits, but that the upload image size limit may differ from the tweet image size limit.
Thanks!


#5

Sorry about the confusion! This question has surfaced many times so we are in the middle of updating the docs to make it clearer. It may take a bit since we are heading into the end of the year, but the updates should be soon.


#6

To follow up on this thread, the documentation has been updated to make this clearer. Here is the diff:

Original
- Maximum image size is 5MB and maximum video size is 15MB.

As of 5 Jan 2016
`- The maximum image size for this endpoint is 5MB. Depending on how the image is used, further limits apply. For example, if the image is attached to a Tweet, the maximum limit in this case is 3MB.

  • The maximum video size for organic Tweets is 15MB.`

#7

Awesome, thanks Jbulava!


#8