Image media uploaded but not shown in post update

rest
api

#1

Hi guys,

We use upload media (/1.1/media/upload.json) to upload an image:
Example response:
{“media_id”:634344556188844032,“media_id_string”:“634344556188844032”,“size”:80893,“expires_after_secs”:86400,“image”:{“image_type”:“image\/png”,“w”:810,“h”:350}}

Then we use status update (/1.1/statuses/update.json) to create a new post and attach the uploaded image to the new post.
Example response:
{
“created_at”: “Thu Aug 20 12:41:44 +0000 2015”,
“id”: 634344563180703744,
“id_str”: “634344563180703744”,
“text”: “Four Billion-Dollar Startups That Were Told Their Idea Was Stupid \u2014 Medium by @benhoffman_ on @Medium https:\/\/t.co\/JqlKXPIaLx”,
“source”: "\u003ca href=\"
http: \ /\/www.snipandshare.com\ " rel=\"
nofollow\ “\u003eSnip and Share\u003c\/a\u003e”,
“truncated”: false,
“in_reply_to_status_id”: null,
“in_reply_to_status_id_str”: null,
“in_reply_to_user_id”: null,
“in_reply_to_user_id_str”: null,
“in_reply_to_screen_name”: null,
“user”: {
“id”: 3037627595,
“id_str”: “3037627595”,
“name”: “Cricketer”,
“screen_name”: “cricket15now”,
“location”: “United Kingdom”,
“description”: “Part-time cricketer, full-time techie”,
“url”: null,
“entities”: {
“description”: {
“urls”: []
}
},
“protected”: false,
“followers_count”: 24,
“friends_count”: 57,
“listed_count”: 3,
“created_at”: “Sat Feb 14 21:09:35 +0000 2015”,
“favourites_count”: 4,
“utc_offset”: null,
“time_zone”: null,
“geo_enabled”: false,
“verified”: false,
“statuses_count”: 483,
“lang”: “en”,
“contributors_enabled”: false,
“is_translator”: false,
“is_translation_enabled”: false,
“profile_background_color”: “C0DEED”,
“profile_background_image_url”: “http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png”,
“profile_background_image_url_https”: “https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png”,
“profile_background_tile”: false,
“profile_image_url”: “http:\/\/pbs.twimg.com\/profile_images\/621308091737485312\/YH-revo3_normal.jpg”,
“profile_image_url_https”: “https:\/\/pbs.twimg.com\/profile_images\/621308091737485312\/YH-revo3_normal.jpg”,
“profile_banner_url”: “https:\/\/pbs.twimg.com\/profile_banners\/3037627595\/1436966351”,
“profile_link_color”: “0084B4”,
“profile_sidebar_border_color”: “C0DEED”,
“profile_sidebar_fill_color”: “DDEEF6”,
“profile_text_color”: “333333”,
“profile_use_background_image”: true,
“has_extended_profile”: false,
“default_profile”: true,
“default_profile_image”: false,
“following”: false,
“follow_request_sent”: false,
“notifications”: false
},
“geo”: null,
“coordinates”: null,
“place”: null,
“contributors”: null,
“is_quote_status”: false,
“retweet_count”: 0,
“favorite_count”: 0,
“entities”: {
“hashtags”: [],
“symbols”: [],
“user_mentions”: [{
“screen_name”: “benhoffman_”,
“name”: “Benjamin Hoffman”,
“id”: 2237163510,
“id_str”: “2237163510”,
“indices”: [78, 90]
}, {
“screen_name”: “Medium”,
“name”: “Medium”,
“id”: 571202103,
“id_str”: “571202103”,
“indices”: [94, 101]
}],
“urls”: [{
“url”: “https:\/\/t.co\/JqlKXPIaLx”,
“expanded_url”: “https:\/\/medium.com\/benhoffman\/four-billion-dollar-startups-that-were-told-their-idea-was-stupid-97a02cfa5e7?_ts=1440074551149”,
“display_url”: “medium.com\/benhoffman\/fo\u2026”,
“indices”: [102, 125]
}]
},
“favorited”: false,
“retweeted”: false,
“possibly_sensitive”: false,
“lang”: “en”
}

Result: Image is missing.

Issue is that it is happening randomly. Sometimes images are displayed and sometimes they are not.
What could potentially be the issue?

Thank you guys!


Image media uploaded but not shown in post update
#2

I’ve noticed a strange behavior. Sometimes when tagging users the attached image is not displayed…


#3

We are experiencing the same issue.

Even though there were no users tagged in my post (in user_mentions entities), image was still missing on Twitter.

I also got the media_id_string with success response and subsequently passed the same to statuses/update.json endpoint. The tweet text posted successfully but image was still missing.

Here, I receive the following response from statuses/update.json
{“created_at”:“Fri Oct 30 08:50:34 +0000 2015”,“id”:660015928130863105,“id_str”:“660015928130863105”,“text”:“Test tweet with upload media along with tweet https://t.co/lwQOXNsKD3",“source”:"\u003ca href=“http://my.quesocial.com” rel=“nofollow”\u003eQUEsocial\u003c/a\u003e”,“truncated”:false,“in_reply_to_status_id”:null,“in_reply_to_status_id_str”:null,“in_reply_to_user_id”:null,“in_reply_to_user_id_str”:null,“in_reply_to_screen_name”:null,“user”:{“id”:1724846510,“id_str”:“1724846510”,“name”:“Yashwant Garad”,“screen_name”:“Yashwant_Garad”,“location”:“Pune, Maharashtra”,“description”:"",“url”:null,“entities”:{“description”:{“urls”:[]}},“protected”:false,“followers_count”:22,“friends_count”:19,“listed_count”:1,“created_at”:“Tue Sep 03 08:34:11 +0000 2013”,“favourites_count”:3,“utc_offset”:19800,“time_zone”:“Chennai”,“geo_enabled”:false,“verified”:false,“statuses_count”:154,“lang”:“en”,“contributors_enabled”:false,“is_translator”:false,“is_translation_enabled”:false,“profile_background_color”:“000000”,“profile_background_image_url”:“http://abs.twimg.com/images/themes/theme1/bg.png",“profile_background_image_url_https”:“https://abs.twimg.com/images/themes/theme1/bg.png”,“profile_background_tile”:false,“profile_image_url”:“http://pbs.twimg.com/profile_images/562846037367201792/9MkjAjOi_normal.jpeg”,“profile_image_url_https”:“https://pbs.twimg.com/profile_images/562846037367201792/9MkjAjOi_normal.jpeg”,“profile_link_color”:“3AABE0”,“profile_sidebar_border_color”:“000000”,“profile_sidebar_fill_color”:“000000”,“profile_text_color”:“000000”,“profile_use_background_image”:false,“has_extended_profile”:true,“default_profile”:false,“default_profile_image”:false,“following”:false,“follow_request_sent”:false,“notifications”:false},“geo”:null,“coordinates”:null,“place”:null,“contributors”:null,“is_quote_status”:false,“retweet_count”:0,“favorite_count”:0,“entities”:{“hashtags”:[],“symbols”:[],“user_mentions”:[],“urls”:[{“url”:“https://t.co/lwQOXNsKD3”,“expanded_url”:“http://bit.ly/1MlWUuY”,“display_url”:“bit.ly/1MlWUuY”,"indices”:

can anybody help me here ?


#4

I have the same issue. May I ask if you solved this problem?


#5

Hi there guys,

I’ve managed to solve the issue by trial and error mostly.
Here are my findings:

  • First upload your image;
  1. Uploading image details
  • Upload your image to /1.1/media/upload.json;
  • set request content type header to multipart/form-data (“Content-Type”, “multipart/form-data”);
  • set the file in the request “media”, dataBytes, “nameOfTheFile.imageExtension”, “application/octet-stream”);
  • from the twitter response retrieve the media_id;
  1. Post status on twitter with an image included:
  • Set your tweet data
  • Assign the media_id in a list/array and set it as a value of media_ids;
  1. Troubleshooting:
  • Most of the times the process described above will be successful, however twitter will fault your requests from time to time. You will need to retry your requests.

Do retry in case of the following faulted responses by twitter:

  • Error code 32 - could not authenticate you;
  • Error code 226 - This request looks like it might be automated. To protect our users from spam and other malicious activity, we can’t complete this action right now. Please try again later;
  • Error code 130 - Over capacity / Service Temporarily Unavailable;

Hope it helps you. Godspeed.

Best,
Marjan