I’m trying to implement whatsapp business API but I’m getting forbidden error I think its because i dont have enough permission.
I have also implemented this code on Postman its works fine there but its not working in app i dont know why?
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://graph.facebook.com/v15.0/110474688636083/messages");
request.Headers.Add("Authorization", "Bearer EAAM2wERIcIsBAFSGQD3yCSYRd5II5u7hU1859z8VcpNFlZBjJrqJUR2QrgZADHlHYSCG0zWvpYqVkFlzea9TsN1wnu8ZBZBSiEaXQu5OZAQC63ufVKZAQDHZB25CIq3TBQ9rxr2DdZB1oZBgJtia4eAEBbzqfjwJpXm9M5SZCGhDh7JbK0s1ldz2Od099jHfKrFvnQDZD");
var content = new StringContent("{n "messaging_product": "whatsapp",n "to": ""+WHATSAPPNO+"",n "type": "template",n "template": {n "name": "hello_world",n "language": {n "code": "en_US"n }n }n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
thank you for your time
2
Answers
You did not specify the access token.
TOKEN
here is an placeholder and not a real tokenThis will help you to resolve your issue,
Model files,
Then you need two packages RestClient and Newtonsoft.Json,
Main c# class function,
facebook graph API latest version is v16.0 and not v15.0. So try updating that might also help you.
Changelog
Format is change for sending message in v16.0 check this