Twitter-API-v2-sample-code icon indicating copy to clipboard operation
Twitter-API-v2-sample-code copied to clipboard

The API v2 cut tweet text to 270 characters, but real text length is more then 270 chars

Open eworker2003 opened this issue 2 months ago • 1 comments

Describe the bug The API v2 cut tweet text to 270 characters, but real text length is more then 270 chars. Tweet text contains more then 270 chars: https://x.com/Gurudev/status/1979249076425363763

To Reproduce Steps to reproduce the behavior:

  1. get tweet by id. I use API v2, for this tweet: https://api.x.com/2/tweets?ids=1979249076425363763&expansions=attachments.media_keys&media.fields=url,preview_image_url,variants

  2. result - text is cut to 270 chars: It is heartening to see 210 Naxalites lay down their arms - a step long overdue. The efforts of the Hon’ble Home Minister @AmitShah and @PMOIndia have paved the way for greater peace and prosperity. Congratulations to @PMOIndia and Hon’ble @AmitShah for this commendable

Expected behavior The result text should be: It is heartening to see 210 Naxalites lay down their arms - a step long overdue. The efforts of the Hon’ble Home Minister @AmitShah and @PMOIndia have paved the way for greater peace and prosperity. Congratulations to @PMOIndia and Hon’ble @AmitShah for this commendable achievement.

Additional context Image

eworker2003 avatar Oct 18 '25 09:10 eworker2003

I have asked devcommunity here: https://devcommunity.x.com/t/the-api-v2-cuts-tweet-text-to-270-characters-when-real-text-length-is-more-then-270-chars-280-chars/251379

The solution is

sadev23 X Staff:

Please use tweet.fields=note_tweet to get the complete tweet text

So now I use these urls params: const string urlParams = "&expansions=attachments.media_keys&tweet.fields=note_tweet&media.fields=url,preview_image_url,variants";

"https://api.x.com/2/tweets?ids=" + id + urlParams;

It works. May be it well be good to comment it in samples.

eworker2003 avatar Nov 13 '25 10:11 eworker2003