I'm getting a weird error while configuring welcome message for my Messenger bot. I've been using the same code (as shown below) and it has just been working fine until last night. I tried it with both cURL and Postman. Neither of them works.
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message":{
"text":"Welcome to My Company!"
}
}
]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
Error message when executing the code above:
{"error":{"message":"(#100) Invalid keys \"message\" were found in param \"call_to_actions[0]\".","type":"OAuthException","code":100,"fbtrace_id":"Hn42Wa+hapI"}}%
I can confirm both PAGE_ID and PAGE_ACCESS_TOKEN are correct as trying to delete the welcome message with the following code works fine.
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message":{
"text":"Welcome to My Company!"
}
}
]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
Also, the code I'm using is exactly the same as shown on the Facebook official API doc. I don't understand why it's saying "message" is not a valid key. Is anyone experiencing the same problem? Did Facebook change their api?
Any help will be much appreciated!
The docs are now updated, you need to define your payload in payload parameter now (a UTF-8 encoded string), eg:
"call_to_actions":[
{
"payload":"USER_DEFINED_PAYLOAD"
}
]
Docs updated:
https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text
Example:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"greeting",
"greeting":{
"text":"Welcome to My Company!"
}
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
I get the same issue and fix it.
I think your json of request is
let messageData = {
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"payload":"welcome_payload"
}
]
}
request({
url: 'https://graph.facebook.com/v2.6/me/thread_settings',
qs: {access_token:token},
method: 'POST',
json: {
messageData
}
}
but it will not work and log will say you have no "setting_type" = =a
try this one
request({
url: 'https://graph.facebook.com/v2.6/me/thread_settings',
qs: {access_token:token},
method: 'POST',
json: {
setting_type:"call_to_actions",
thread_state:"new_thread",
call_to_actions:[
{
"payload":"welcome_payload"
}
]
}
}
it work for me.
This error was due to an API change.
New call:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[{
"payload":"START"
}]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_TOKEN>"
Just add a payload like {"payload":"START"}
If a user press the "Getting started" button, you receive this payload in your messageHandler (webhook). Check if $incomingMessage == "START" and send back your structured message, or whatever you want.
Messages like before are not supported anymore.
Bug report: https://developers.facebook.com/bugs/1751749508372552/
Related
The API is : /repos/{owner}/{repo}/pulls.
I used the correct token, and the request body is :
data = {
"base": "master",
"head": "owner:master",
"title": "title",
}
The head is like this:
{'Accept': 'application/vnd.github.v3+json', "Authorization": "token {}".format(git_token)}
Then I call the pull API. Returned 200.
<Response [200]>
Why? Maybe the request body wrong?
The Pull Request API specified the answer:
Status: 201 Created
Try and anddapt their example to your repository, to see if it does work:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/pulls \
-d '{"head":"head","base":"base"}'
I am working on a Akka-Http project in which I am writing a POST endpoint http://localhost:8080/api/v1/internal/admin/import which requires a header with an access token.
My curl request is as follows
curl --location --request POST 'http://localhost:8080/api/v1/internal/admin/import' \
--header 'Content-Type: application/json' \
--header 'Accept: text/plain' \
--header 'Authorization: correct-token' \
--data-raw '{
"id": 100,
"name": "test"
}'
When the access token is incorrect, I get the http response in the exact format that is expected
"status": {
"code": 403,
"error": "authorization_error",
"details": "Invalid token"
}
}
But as soon as I provide a correct token in the header, the http request is successful, but I get a weird message HTTP method not allowed, supported methods: GET.
Just before sending the correct response, I tried to print the json and its correct. My code looks as follows :
onComplete(futureR) {
case Success(result) =>
println(s"Success response json is ${Json.toJson(result)}")
complete(result)
case Failure(ex) => complete(
500 -> StatusResponse(ApiStatus(500, None, None))
)
}
The result I am getting on terminal is Success response json is {"status":{"code":0}} which is correct, however in Postman, I keep on getting the error HTTP method not allowed, supported methods: GET.
Any pointers to this problem ? TIA
I tried creating a request via postman with below Request Body with 1 input text,
{
"subject" : "Fill Up the Form",
"content" : "Form Data",
"formMetaData" : {
"id": "myform1234",
"controls": [{
"type": "Circuit.Enums.FormControlType.INPUT",
"name": "Your Name"
}]
}
}
But I am only getting the Content and Subject part in Circuit Sandbox. Form part is missing
Using the Rest API and not the SDK you should replace the ENUMS with strings for the control types.
I have a working code sample in Postman for this
curl -X POST \
https://beta.circuit.com/rest/v2/conversations/6aecff9e-1aa0-46f3-8e24-8519e2956291/messages \
-H 'Authorization: Bearer 11111omitted' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-F 'content=Please fill in the form below' \
-F 'subject=Test form' \
-F 'formMetaData={"id":"myformonbeta","title":"Test Form","controls":[{"type":"INPUT","name":"name","text":"What is your namne ?","rows":1},{"type":"BUTTON","text":"Send"}]}'
Hope this helps
I'm trying to make a HTTP request to modify password from users that are stored into WSO2. I'm using the following request:
{
method: 'PUT',
url: domain + '/wso2/scim/Users/' + userId,
rejectUnauthorized: false,
headers: {
Authorization: 'Bearer ' + scimToken,
'Content-Type': 'application/json'
},
json: true,
body: {
userName : 'foo',
password : 'newPassw0rd'
}
}
But response returns a Java exception (I don't attach it here, because is too long and I think that doesn't have sense. Is related with Apache CXF).
I'm so new with SCIM and WSO2, so I think that I'm making a mistake in the request. Does anyone knows what's wrong?
Thanks!
create user with this request:
curl -v -k --user admin:admin --data '{"schemas":[],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"hasinitg","password":"hasinitg","emails":[{"primary":true,"value":"hasini_home.com","type":"home"},{"value":"hasini_work.com","type":"work"}]}' --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users
update password
curl -v -k --user admin:admin -X PUT -d '{"schemas":[],"name":{"familyName":"gunasinghe","givenName":"hasinitg"},"userName":"hasinitg", "password":"pwd123","emails":[{"value":"hasini#wso2.com","type":"work"},{"value":"hasi7786#gmail.com","type":"home"}]}' --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users/0032fd29-55a9-4fb9-be82-b1c97c073f02
I'm currently trying to implement a Persistent Menu for my Facebook Chatbot. Sadly there are two (completely different) documentation for the implementation which both don't work for me. (Both should work for API v2.6)
https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu
https://developers.facebook.com/docs/messenger-platform/thread-settings/persistent-menu
I used this simple call which is returning an error (#100) The parameter setting_type is required
curl -X POST -H "Content-Type: application/json" -d '{
"persistent_menu":[
{
"call_to_actions":[
{
"type":"web_url",
"title":"Einstellungen",
"url":"https://{{url-part}}.cloudfront.net/",
"webview_height_ratio":"full"
}
]
},
{
"locale":"de_DE",
"composer_input_disabled":false
}
]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token={{token}}"
If I use the second documentation with "setting_type" : "call_to_actions" the same error occurs.
Why I can't set up a Persistent Menu?
The below works for me.
Make sure you are sending the request to the new endpoint, messenger_profile. You have to provide at least a default locale.
curl -X POST -H "Content-Type: application/json" -d '{
"persistent_menu":[
{
"locale":"default",
"composer_input_disabled":false,
"call_to_actions":[
{
"type":"web_url",
"title":"Einstellungen",
"url":"https://{{url-part}}.cloudfront.net",
"webview_height_ratio":"full"
}
]
}
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token={{token}}"