C# Webhook Register




I work in C # and I am trying to mount a bot for direct messages. and of course I want to register a webhook to collect the events.

The problem I have is that I am trying to mount the call but I am always 401 answered.

And then if I try to test the call through POSTMAN, it always returns a
"code": 32,
“message”: “Could not authenticate you.”

I leave the code here.

var oauth = new OAuth.Manager();

            oauth["consumer_key"] = "**************";
            oauth["consumer_secret"] = "****"**;
            oauth["token"] = "****";
            oauth["token_secret"] = "*******";

            var appUrl = "https://api.twitter.com/1.1/account_activity/webhooks.json?url=https://bots.chatbotchocolate.com/api/SAMU/Twitter";
            var authzHeader = oauth.GenerateAuthzHeader(appUrl, "POST");
            var request = (HttpWebRequest)WebRequest.Create(appUrl);
            request.Method = "POST";
            request.PreAuthenticate = true;
            request.AllowWriteStreamBuffering = true;
            request.Headers.Add("Authorization", authzHeader);                

            using (var response = (HttpWebResponse)request.GetResponse())
                string resultado = response.ToString();                                        

I’m desperate and I need a solution.

Greetings and thanks


You need a developer access and your App ID needs to be whitelisted by Twitter first to access the Account Activity API. Did you apply yet?

You will be able to register your webhook once access has been granted.

You can apply here: https://developer.twitter.com/en/apply


Yes, I’m registered since yesterday, what I do not know if I’m really on that white list on twitter


That screenshot shows you are whitelisted for premium 30-day search. The account activity API is not currently shown on the dashboard. Are you sure that you requested access to the account activity API?


I think yes, I followed the steps of registration and send me an email and I see the following by clicking on the link