WhatsApp Business API not sending /message endpoint or test messages to phone - facebook-graph-api

I've setup a WhatsApp Business to test their new WhatsApp API for sending messages. I've followed the getting started guide, but I'm running into an issue when trying to send a test message to my phone.
I tested sending messages using the test message call in the business settings as shown in the guide and I've created my own /messages call in Postman using a permanent token. Both calls return a 200 status, but neither of them actually sends a message to my phone.
To double check my setup, I added a colleagues phone to the setup and he receives the messages and can interact with my webhook via WhatsApp just fine.
Some posts on Stackoverflow mention having to send a message to the test number first, but I was unable to get this to work and my colleague didn't have to do this.
Is there some kind of setting or issue that could explain why I'm not receiving the messages? I've even tried re-installing WhatsApp and setting up my phonenumber again, but that didn't change anything either.
Updates:
I tried validating my phonenumber via the /contacts endpoint, but it keeps returning an auth error. Updating my token to include all Whatsapp permissions did not change this, whatsapp_business_api_data isn't an option to include.
{
"error": {
"message": "(#100) The parameter whatsapp_business_api_data is required.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": ""
}
}
I noticed that my webhook included a status object in change.value.statuses.[0] this mentioned the following:
{ status: 'failed', errors: [{ code: 131000, title: 'Failure due to an internal error. Please retry.' }]}
Next I created a new app and added the Whatsapp integration, I added and validated my phonenumber via a text and tried to send a test messsage. This also doesn't start a conversation nor does it give me any feedback. If I try to add my phonenumber again, by adding it as another number, I cant and get the error Reason: VERIFIED

So it's not the best answer to the issue, but I got a new phonenumber to test this out on. I added it to my test numbers, validated the number, sent a test message to the new number and received it just fine.
I'm not sure if the issue was caused by a privacy setting or an issue on Facebook side, but the old number still doesn't receive the messages.

You can only send a template type message as your first message to a user.
From the error message, it looks like you're hitting the Graph API version lower than v12.0. Try with V12.0 and higher.
Also, it will be helpful if you can paste the response you get from your API request and in your Webhook.

I had the same error code but with a different message:
I fixed it by deleting the whatsapp number here and adding it again.

Check the company code. It should be prefixed.
{ "messaging_product": "whatsapp", "to": "91xxxxxxxx", "type": "template", "template": { "name": "hello_world", "language": { "code": "en_US" } } }

Some colleagues weren't receiving any messages.
In my case, the problem was that they haven't accepted the WhatsApp's Terms and Condition.
To accept the terms, they had to start a new conversation with the business.
A popup appears to review and accept the terms.
Once accepted, they received the messages without problem.
PS: I'm in Spain, maybe it's a European Union thing...

I got the same issue, resolved it by sending the message multiple times through the api in watsapp setup, getting started page. Also accepted the number in personal watsapp by allowing it to continue.

Related

Trying to add Facebook Get Started button

I am trying to add a Facebook Messenger get started button to a bot I am working on. The API documentation says I need the following code:
{
"get_started":{
"payload":"<GET_STARTED_PAYLOAD>"
}
}
I'm using the Chrome Postman App as I've been trying to mess around with Curl and I don't really like it.
I set up my URL as follows:
https://graph.facebook.com/v2.6/me/thread_settings?access_token=(MY-ACCESS-TOKEN)
I know the access token works because I used it when setting up my bot's greeting and it worked.
Body of the request is as follows:
{
"get_started":{
"payload":"GET_STARTED"
}
}
When I try to send, I get the following error:
{
"error": {
"message": "(#100) The parameter setting_type is required",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "BC+QucQjBck"
}
}
The API documentation doesn't say anything about needing to specify "setting_type", nor does it say what "setting_type" should be. I know that I need "setting_type":"greeting" for setting the greeting message.
Any suggestions?
If it's easier to make sense of what I'm doing, here is a screenshot:
Screenshot of Error
You are using the wrong endpoint.
The Getting Started button is part of Messenger Profile API, so you have to POST to
https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
^^^^^^^^^^^^^^^^^^ not "thread_settings"
https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api#post

Autodesk Data Management API 403-Error

I am trying to receive data via Autodesk Data Management API. So far I've created an Forge-App and connected it with a BIM360 Integration.
Then I wanted to get a list of all hubs, but when I do so, I receive an JSON-Object which contains a warning:
warnings: [{
"AboutLink":null,
"Detail":""You don't have permission to access this API",
"ErrorCode": "BIM360DM_ERROR",
"HttpStatusCode": "403",
...
}]
I called the webservice via AJAX wich looks like that:
this.getToken(function(token) {
$.ajax({
url: "https://developer.api.autodesk.com/project/v1/hubs",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer "+token);
}
}).done(...);
The token is a 3-legged one. I am not sure which API I do not have permission for because I am pretty sure, that I have permission for BIM360.(I created the Integration as an administrator).
In addition to was ZHong mentioned, I would suggest you try this sample. It will ask you to provision your Forge Client ID under your BIM 360 settings, just follow the steps that the app will present.
On both 2- or 3-legged, the app accessing the data (Forge Client ID) needs authorization from the account admin. Without that, the Hubs endpoint will not return your BIM 360 hub, and inside that, the sample applies for Projects endpoint.
Does everything else work fine? For example, can you get all the hubs successfully? I just verified on my side, and I can see the response including the same warning as you mentioned, but the hubs are listed correctly, and you can get the projects/items/versions without problem. I pasted my postman response as follow.
If you check the blog https://forge.autodesk.com/blog/tutorial-using-curl-3-legged-authentication-bim-360-docs-upload, it also has the same warning, but seems no impact to the following operation. I am not exactly sure what the warning means, l will check and update the details, but so far, it seems you can ignore it for now.

Need to handle 404 errors when using the Google Admin SDK and searching for users

I am having trouble catching error when using the Google Admin SDK and .NET. There was not much information on practical examples using this on Google's website, that I could find.
Alas, I have working code that will search a Google Apps domain for a user account and return properties about that user account. What I do not have is error handling for scenarios when the searched for user account is not found (indicating that the user does not exist).
It seems this situation is returned as an HTTP 404 response. Great. No problem in that, but I cannot seem to handle this gracefully in my app. IIS is simply throwing a "The resource could not be found" error mesage at /xxx/appname/DefaultRedirectErrorPage.aspx. I am not sure where this is coming from as it is not defined in web.config or default.asax.
If there was a practical example of how to handle such a simple response from Google, using .NET, that would be great.
I dont know anything about .NET library... BUT I have worked with the underlying HTTP requests (I'm using PHP). The API may not be returning what you think it should...
If there is an error, the API should return an "error" object in the JSON response. I check for that when looking for errors.
In my interaction with the directory API, when retrieving a user that does not exist the JSON response does not contain a user object. Even with NO users returned it DOES return a 200 response, not an error.
for example, if I search for a user that does NOT exist, Google sends back something like this:
{
"kind": "admin#directory#users",
"etag": "\"LOTSOFCHARACTERSHERETHATAREAKEYOFSOMEKIND\""
}
when I search a valid user, the JSON I get back is like this:
{
"kind": "admin#directory#users",
"etag": "\"LOTSOFCHARACTERSHERETHATAREAKEYOFSOMEKIND\""
"users": [
"kind": "admin#directory#user",
"id": "109020414202478541143",
// lots of other properties here //
]
}
Are you using Google's .NET library or your own? Either way, I would check to make sure that the user object you're trying to access actually exists when an invalid user is searched.
hope that helps.
A couple years late but I was trying to figure out the same thing and found that Google doesn't have any error handling documentation around their Admin SDk. I was able to work around it with a try...catch in Google Apps Script.
try {
var page = AdminReports.CustomerUsageReports.get(date, {
parameters: parameters.join(','),
maxResults: 500,
customerId: customerId
});
} catch (error) {
console.log(error.code);
console.log(error.message);
}

Mailgun send via HTTP API doesn't seem to send

I am trying to use Mailgun to send via the HTTP API as follows:
Python:
def send_simple_message(string):
return requests.post(
"https://api.mailgun.net/v2/samples.mailgun.org/messages",
auth=("api", "my-key"),
data={"from": "<me#mydomain.com",
"to": ["to#recipient.com"],
"subject": "",
"text": string})
My domain is verified using the CNAME records supplied, and I tried sending a couple of test strings.
Nothing visible happened, at all, from my Python script - didn't appear in sent items (gmail). So I tried manually via Terminal, and got the response: <Response [404]>.
Updating the address to mydomain.com (thanks #kwatford) I get <Response [200]> (success).
However, this was a test email I sent to myself (on a different address). I have not received the message, and it is not in the sent box of me#mydomain.com either. What have I done wrong?
Thanks to #kwatford for identifying the issue, exact solution as follows for anyone else confused by the example:
https://api.mailgun.net/v2/samples.mailgun.org/messages should be replaced by:
https://api.mailgun.net/v2/yourdomain.com/messages.
What I initially tried for a [200] response was simply http://mydomain.com which is incorrect.
Further, I was wrong to expect it to appear in sent items, though it does appear (now that I have the correct POST address!) in cp > logs on mailgun.com

Can there be an error in data that causes a graph to give a warning?

When I use the graph api to get public data from pages, I get for some pages a warning and other pages work fine.
The warning is: file_get_contents(http://graph.facebook.com/318993554879922) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in ....
When I look at the data of this company in the graph tool on Facebook, I can see everything I need. Everything look fine
How can I prevent this (or better: what advice can I give to the page owbers whose data I want to show on my website to change)?
I used to think that it was a setting in the profile picture because all pages that went wrong had a "custom" setting. That setting could not be changed. But I asked a page owner to upload a new picture and the problem stayed.
It's because the request is unsupported.
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
So the API will return an HTTP 400 response to you.
It's either this object doesn't exist, was deleted or is a bug.