This project has moved and is read-only. For the latest updates, please go here.

I am trying to send a Direct Message using the LinqToTwitter api and suddenly I get a 401 error

Mar 30, 2013 at 3:32 AM
I am trying to send a Direct Message using the twitter api and suddenly I get a 401 unauthorized error

it use to work before so I don't know what to do? I am using LingToTwitter API
using C#

any clue anyone?

sample code: this code worked fine before. am I doing something wrong?

var result= twitterCtx.NewDirectMessage(UserIdGoesHere, "the direct message text goes here");
Mar 30, 2013 at 3:40 AM
Edited Mar 30, 2013 at 3:45 AM

DMs are working fine for me right now. Here are a few ideas on what to look for:
  1. Make sure the user performing the DM can authorize and perform other actions.
  2. Duplicate DMs aren't permitted - I'll usually test with a timestamp appended to the message to guarantee uniqueness.
  3. Applications have permissions for DMs, so you might want to check what the DM settings are.
  4. Try to DM a different user and/or DM from the account of a different user. It's possible for someone to deny your ability to DM to them.
  5. Look at the HttpError and ErrorCode, properties of the TwitterQueryException to see if they provide any insight.
I have a FAQ that has extensive coverage of how to troubleshoot 401 exceptions. Of course the 401 coverage in the FAQ covers authentication and it sounds like the user is already authenticated, but they just need to send a DM, but I mention it just in case.