Rest Api - reply to to tweet



Hi guys,

I encountered a bit of a stumbling block. I’ve implemented several features thus far, I can create new tweets, I can send direct messages and search.
What I am trying now is to reply to a tweet. So, I perform a search first, get some tweets back and get their id.

From what IB’ve been reading I am supposed to use the same endpoint as the one used to post a new tweet:

I need to pass not only the status which is the message itself but also in_reply_to_status_id which is the id of the tweet I want to reply to.
I have a working call which creates new tweets and i simply added the extra parameter in_reply_to_status_id

This is done in two places. First in the base string which is used to create the composite key. It looks like this :

var baseFormat = “oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}” +

i just chuck the right values in there. Then I add it to the post body of the request which looks like this :

var postBody = string.Format(“status={0}&in_reply_to_status_id={1}”, Uri.EscapeDataString(status), tweetId);
the content type is application/x-www-form-urlencoded. I am using C# for this, just in case you’re wondering although that makes no difference. it’s the process I am interested in.

So this is what I changed compared to a normal call which creates a new tweet and that code actually works. Once I add the extra parameter in_reply_to_status_id in the two places mentioned, I then get a 401 unauthorized error and i am not sure why. I must be missing something but I can’t see what it is.

Any ideas ?


How you make API calls/construct your URL’s looks very unstable and I would recommend to use a proper library that handles Twitter API calls.


this is the twitter api, so I am not sure why you call it unstable. The question remains…