Getting invalid Tweet id and id_str


I am using Ruby’s Twitter Gem ( to interact with Rest API.

For some people, when I am posting a tweet through API, getting wrong Tweet id.
Both my Tweet id and id_str are same, but when I go to the profile, its showing a tweet with different id.

For example for when I posted to @PebbleInWaters, I got tweet id 829287112583286784 in the response but the actual tweet id is 829287114386894848.

Please help me to solve this issue.


Are you using any Javascript in your code, or only Ruby? This sounds like a classic large integer issue.

The difference between id and id_str is documented here.


I am using only Ruby… And read about classic large integer issue, but my id and id_str are same… Both are wrong… And its happening only for certain people only… Is this something related to privacy settings, @andypiper???


I don’t see how this can relate to privacy settings. I cannot retrieve either of those Tweet IDs, however (that may be related to privacy settings). Can you provide an example code snippet that demonstrates the issue?

@client = do |config|
  config.consumer_key        = ENV['TWITTER_CONSUMER_KEY']
  config.consumer_secret     = ENV['TWITTER_CONSUMER_KEY_SECRET']
  config.access_token        = token
  config.access_token_secret = token_secret

post_result = @client.update_with_media(content, image_file)
post_permalink =
post_result = post_result.to_json

a part of post_result is like this

{"created_at":"Wed Feb 08 11:13:49 +0000 2017","id":829287112583286784,"id_str":"829287112583286784","text":"You must agree that the Classic Coffee without Chicory tastes thousands times better #ClassicCoffeeBrews"}

Whem I am trying to access that tweet am getting error.

But when I went to his profile and understood the tweet id is 829287114386894848
See the post

It’s happening for some 5 or 6 people only. That’s why I asked it’s related to any privacy settings. If u notice, the link in the content is also changed. What I got in response is, but in the actual tweet its showing

Please have a look @andypiper