Skip to content

Getting an IllegalArgumentException when deserializing JSON response to create tweet #61

Open
@broadbear

Description

Getting an IllegalArgumentException when deserializing JSON response to create tweet. It looks like the TweetCreateResponseData class doesn't contain fields present in the create tweet response JSON since Sept 20, 2022:

https://developer.twitter.com/en/docs/twitter-api/fields

By default, the Tweet object only returns the id and the text fields, and for Tweets created since September 29, 2022, the edit_history_tweet_ids field.

Expected behavior

CreateTweetRequest instance is created and populated with tweet information from the JSON response to create a tweet.

Actual behavior

Getting an IllegalArgumentException when deserializing JSON response to create tweet. The error seems to be related to a newish JSON field that was added to the response to create tweets via the TwitterApi.tweets().createTweet() api call. The exact error is:

java.lang.IllegalArgumentException: The field edit_history_tweet_ids in the JSON string is not defined in the TweetCreateResponseData properties. JSON: {"edit_history_tweet_ids":["1671964017076883456"],"id":"1671964017076883456","text":""Ahoy!""}

Steps to reproduce the behavior

Use the twitter api to create a tweet and attempt to deserialize the response directly to a TweetCreateResponse object.

TweetCreateResponse result = apiInstance.tweets().createTweet(createTweetRequest);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions