twitterCtx.NewDirectMessage Parentheses error

Nov 19, 2012 at 7:07 PM

Hi, when I pass Parentheses in the message I get a non-specific error. Can you please reproduce or suggest a solution?

Thanks!

Coordinator
Nov 19, 2012 at 11:59 PM

Hi,

Please post an example of the query you're having a problem with - also include exception details.

I recently fixed a bug where some characters weren't being encoded properly, which is part of the most recent release. If you aren't using the latest release, this might be something to try.

When looking at the exception message, look at the Response property of the TwitterQueryException, if available, to see what Twitter is returning.

@JoeMayo

Nov 20, 2012 at 5:52 PM

Joe,

Here is the code -

var message = twitterCtx.NewDirectMessage(userId, "Test message with (parentheses)");

I'm using the latest build.

The error I get is "Could not authenticate you". When I remove the "(" and ")", it works fine.

Thanks!

Coordinator
Nov 20, 2012 at 11:50 PM

I'm not getting an error. I'm still thinking that it's an encoding issue. Here's what Fiddler shows when I send it:

   POST https://api.twitter.com/1.1/direct_messages/new.json?user=16761255&text=Test%20message%20with%20%28parentheses%29 HTTP/1.1

Please run this again and show me the first line of the Request from Fiddler, as I did above. Be sure to not include the Authorization header.

Also, what locale are you?  I'm en-US.

@JoeMayo

Nov 27, 2012 at 6:29 PM

Joe, sorry, haven't had time to test this in fiddler yet.. Will post my response soon. However simply clicking on the link above gives me this and I'm in en-US -

{"errors":[{"message":"Bad Authentication data","code":215}]}
Coordinator
Nov 27, 2012 at 10:15 PM

No problem - if you find anything more that helps reproduce the problem, let me know.

All Twitter queries require OAuth authentication - so the error you received by clicking that link, which is an unauthenticated query, makes sense.

@JoeMayo

Coordinator
Dec 17, 2012 at 3:26 AM

I recently ran into a problem with certain characters being unescaped by the Uri class in .NET 4.5, including parenthesis. This sounds very similar to your problem.  Are you using .NET 4.5? 

After doing everything I can to work around it, including config file settings that don't work and reflection hacks, I submitted this to Microsoft connect:

http://connect.microsoft.com/VisualStudio/feedback/details/774499/uri-doesnt-recognize-schemesettings-dontunescapepathdotsandslashes-in-net-4-5

Hopefully, I'll get a quick work-around or explanation.

@JoeMayo