Twitter API media/upload image size issue



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:\/\/\/eMKaVbqIah",
    "favorited": false,
    "retweeted": false,
    "retweet_count": 0,
    "favorite_count": 0,
    "user": {
      "name": "Varad Mondkar",
      "screen_name": "varadmondkar",
      "profile_image_url": "http:\/\/\/profile_images\/378800000478332640\/80595cf404df09d5c52635f09381c0b1_normal.jpeg",
      "profile_image_url_https": "https:\/\/\/profile_images\/378800000478332640\/80595cf404df09d5c52635f09381c0b1_normal.jpeg"
    "entities": {
      "media": {
        "id": 728443181084213248,
        "media_url": "http:\/\/\/media\/ChvzNreUgAAYS0L.png",
        "media_url_https": "https:\/\/\/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'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'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.


First clear cache then upload


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.


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


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: