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
Related
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.
I am facing an exception when trying to use Instagram OEmbed.
As stated in this page:
https://developers.facebook.com/docs/graph-api/reference/instagram-oembed/
I sent an HTTP GET request to this endpoint:
https://graph.facebook.com/v12.0/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b/&app
As stated in the documentation, I am using the "url" querystring parameter. However, I am getting an exception such as:
{
"error": {
"message": "(#200) Provide valid app ID",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "Acr4on4TtEYPIc2RQwqNmDL"
}
}
So there is an error clearly stating that I need to "Provide valid app ID". However, there is no information about how to provide that app ID. I've tried a few, including:
https://graph.facebook.com/{app_id}/v12.0/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b/
and
https://graph.facebook.com/v12.0/{app_id}/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b/
with no luck. I am looking forward for solutions.
As CBroe pointed out in the comments, you need a valid access token, which you could add at the end of your url like this:
https://graph.facebook.com/v12.0/instagram_oembed?url=https://www.instagram.com/p/CUsIdc5ql2b?access_token=YOURTOKEN
You can look up further documentation here:
https://developers.facebook.com/docs/graph-api/overview/
Since this did not solve the issue for me, I will post my solution.
One key difference is that I am using the SDK while the poster appears to be handling the url themselves.
FacebookAdsApi.init(
access_token=credentials.password
)
response = AdAccount(self.ad_account_id).get_insights(
**request_kwargs
)
If you're handling requests like this, make sure that you're specifying access_token=xxx as the token is a kwarg. Passing the token directly during initialization without specifying access_token will not throw an error until you actually make a request. However, most other issues with initialization DO throw errors. So it's very easy to get mislead into believing the initialization is not the issue when in fact it is.
I currently have an API with multiple resources within our API Gateway, I'm working on a a Swagger UI page for the same.
A lot of the swagger ui definition I have written myself, although I know there is export functionality - it doesn't seem 100% ready yet.
When using the Try it out button from swagger, if I get back a 200, this is handled perfectly and the result shows as expected. I am trying to get the error codes to display and this is where I am stuck.
In API Gateway I have create a 401 in my Method response, including some allowed headers, this is being used in my Integration Response for HTTP status regex of Unauthorized.* - the content of this is just being passed through.
My swagger UI definition response looks like this (for the 401 in particular):
"401": {
"description": "Unauthorized",
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
}
},
This is just expecting a string response. My `produces' has everything needed, just in case;
"produces": ["application/json",
"text/json",
"application/xml",
"text/xml"],
The result through the inspector is correct -
However my swagger still produces this:
I have tried a multitude of things, including assigning an object to the response type, changing my regex expression to 4\d{2} to catch any 400 error, updated the definition produces - all with no luck.
Let me know if there is any other information needed to help.
I'm assuming you're using a custom authorizer or Cognito authorizer and this is what is producing the 401?
Unfortunately there is a known limitation where error methods, such as 401 or 403 from an authorizer, will not contain configured header mappings.
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);
}
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.