Hello
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