Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.io.IOException: Failed deserialization for ProblemOrError #72

Open
elephant-giraffe opened this issue Jan 11, 2024 · 0 comments
Open

Comments

@elephant-giraffe
Copy link

elephant-giraffe commented Jan 11, 2024

When calling twitter v2 api by twitterApi.users().findMyUser() when user's accessToken, the user's twitter account is suspened, but the api does not deserialize the ApiException properly.

TwitterCredentialsOAuth2 oAuth2Credential = new TwitterCredentialsOAuth2("devClientId", "", request.getAccessToken(), "", false);
TwitterApi twitterApi = new TwitterApi(oAuth2Credential);

Get2UsersMeResponse response = twitterApi.users()
                .findMyUser()
                .userFields(userFields)
                .tweetFields(tweetFields)
                .expansions(expansions)
                .execute();

then, it catches the Exception

com.google.gson.JsonSyntaxException: java.io.IOException: Failed deserialization for ProblemOrError: 0 classes match result, expected 1. Detailed failure message for oneOf schemas: [Deserialization for Error failed with `The required field `code` is not found in the JSON string: {"detail":"The user used for authentication is suspended","title":"Forbidden","status":403,"type":"https://api.twitter.com/2/problems/user-suspended"}`., Deserialization for Problem failed with `The value of the `type` field `https://api.twitter.com/2/problems/user-suspended` does not match any key defined in the discriminator's mapping.`.]. JSON: {"detail":"The user used for authentication is suspended","title":"Forbidden","status":403,"type":"https://api.twitter.com/2/problems/user-suspended"}

It does not handle the type of Problem or Error properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant