Failure when trying to upload some images. "The validation of media ids failed."


I am trying to uploading images but getting bad request error with ““errors”: [
“code”: 324,
“message”: “The validation of media ids failed.”
I am making call to:
These images also failed when tried to post natively on twitter with “internal server error”.
Images are:
All of the images have width > 4000 px.
Reducing width passes the images. But I cannot find any documentation for this.
Please confirm the reason of the failure? and solution for the same.

Creating tweet with image: "The validation of media ids failed"
Problem tweet with media

POST statuses/update_with_media is deprecated, you should be using POST media/upload insead.



When I hit, I’m seeing:

"photo_size_limit": 3145728,
  "photo_sizes":  {
    "thumb":  {
      "h": 150,
      "resize": "crop",
      "w": 150
    "small":  {
      "h": 480,
      "resize": "fit",
      "w": 340
    "medium":  {
      "h": 1200,
      "resize": "fit",
      "w": 600
    "large":  {
      "h": 2048,
      "resize": "fit",
      "w": 1024

The way the dimension limits are worded seems to suggest they represent the max dimensions returned for the various thumbnail sizes rather than a limit on the uploaded media itself, but the documentation is vague.

That said, I encountered the same issue (API rejection, and ‘Internal Server Error’ when uploading natively) for image sizes (PNG, in case it matters) starting at 4097px width or height.

The fact that the images fail when uploading natively suggest that this has nothing to do with the fact that the method is deprecated. The same method works perfectly fine for smaller images.

I think there’s a bug in the exception returned. Or is there not supposed to be a dimension limit?


According to Uploading Media uploaded media just has a total size limit, not a limit on dimensions. The photo_sizes should be the dimensions of sizes available from Twitter.

Maximum file size is available in the “photo_size_limit” field from GET help/configuration.


Also this seems to be a duplicate of this thread:


I believe that there is an undocumented limit on the dimensions of an image. Try uploading an image well below the 5MB (current) image size limit with large dimensions as mentioned above >4097px and you will get this error code back.