POST friendship/create returns 401


#1

I’m getting 401 when POSTing to “friendship/create” using Twitter4j’s “createFriendship(String userName, boolean follow)”

The OAuth credentials I’m using work for other calls (namely “lookupUsers(String[] screenNames)” “getUserTimeline(String userName)”).

I’ve tried the suggestions of other threads. Specifically, the app associated with these credentials has:
1). All of its Settings fields declared (CallbackURL, etc.).
2). Its Permissions are set to “Read, Write and Access direct messages”.
3). The Keys and Access Tokens were regenerated after those attributes were set.

My system clock seems to be set properly.

Are there any other ideas about what might be causing this call to fail?


#2

Does it return the error for all userNames or just specific ones? Have you double/triple checked that the userName is a valid Twitter screen_name? AKA it should be the twitterapi part of https://twitter.com/twitterapi.

You should also probably be using createFriendship(String userName) unless your users explicitly want notifications turned on for that user.


#3

@abraham You’re right. It was the userName. Thanks for the suggestion.