Twitter API media/upload image size issue

media-upload

#1

Twitter API media/upload has image size limit <=5mb as per documentation.
But still it is not accepting my images having sizes from 5kb to 5mb. It is throwing me error something like “file size is exceeding”.
It is only accepting images with size below 5kb.

Example :-
When I post an image with 2KB size (media/upload API)
Response I get :- (SUCCESS)

{
  "data": {
    "created_at": "Fri May 06 04:36:03 +0000 2016",
    "id": "728443182682267648",
    "text": "See https:\/\/t.co\/eMKaVbqIah",
    "favorited": false,
    "retweeted": false,
    "retweet_count": 0,
    "favorite_count": 0,
    "user": {
      "name": "Varad Mondkar",
      "screen_name": "varadmondkar",
      "profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/378800000478332640\/80595cf404df09d5c52635f09381c0b1_normal.jpeg",
      "profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/378800000478332640\/80595cf404df09d5c52635f09381c0b1_normal.jpeg"
    },
    "entities": {
      "media": {
        "id": 728443181084213248,
        "media_url": "http:\/\/pbs.twimg.com\/media\/ChvzNreUgAAYS0L.png",
        "media_url_https": "https:\/\/pbs.twimg.com\/media\/ChvzNreUgAAYS0L.png",
        "type": "photo"
      },
      "urls": [
        
      ]
    }
  }
}

When I post an image with size above 5-6KB (media/upload API)
Response I get :- (FAILED)
(Response is to big so I am coming to main point without posting whole json)

error: {
"status_code": 200,
"message": Server error: `POST https://upload.twitter.com/1.1/media/upload.json?media='IMAGE-DATA'` resulted in 503 Service Temporarily Unavailable` response:{"errors":[{"message":"Over capacity","code":130}]}
}

Sometime I get error as :

error: {
"status_code": 200,
"message": Client error: `POST https://upload.twitter.com/1.1/media/upload.json?media='IMAGE-DATA'` resulted in a `400 Bad Request` response:\n\n"
}

So the success percent for uploading image above 5-6KB is ZERO :frowning:

Please help me with this.
Thank you.


#2

First clear cache then upload


#3

Can you be specific about the exact error you are seeing, and provide example images that succeed and fail?

Be aware of this media/upload limitation too:

The filesize limit above is enforced by the media upload endpoint. In addition, there is a separate product entity specific filesize limit which is applied when calling the Tweet creation (or similar) endpoints with media_id. For example, it is possible to upload a 5 MB image, but the Tweet creation endpoint requires images to be <= 3 MB.


#4

Hi @bitbytedev Thank you for your reply
Which cache you are talking about?


#5

Hi @andypiper Thank for your reply. I have updated my question.
I have referred API document of twitter but still it is not accepting my image between 5KB - 5MB :frowning: