Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Messenger bot error: The parameter recipient is required

the bash command I used to connect the bot is: curl -ik -X POST 'https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken'

My error message is:

{"error":{"message":"(#100) The parameter recipient is required","type":"OAuthException","code":100,"fbtrace_id":"EFqWAGq2ABs"}}

Do anyone how to solve it ?

like image 250
Stefano Franzoni Avatar asked Jun 05 '16 20:06

Stefano Franzoni


4 Answers

Just in case anyone missed this, I encountered this issue when I accidentally use the wrong content type - I was using application/x-www-form-urlencoded instead of application/json

So my advise overall is,

  • Check if you are indeed passing the parameter
  • Double check the characters and encoding
  • Make sure to use the correct endpoint
  • and Make sure to use the correct content type when posting the JSON Request.
like image 138
Alvin Reyes Avatar answered Oct 05 '22 16:10

Alvin Reyes


You need to send the recipient id param. Try:

curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"YOUR RECIPIENT ID" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=YOUR_ACCESSTOKEN"

Best regards.

like image 31
Johalf Farina Avatar answered Oct 05 '22 15:10

Johalf Farina


There is another reason for this error message: when you send incorrect characters (like a -tab-) Facebook return this error as well so check your return text on special chars.

like image 43
Jeroen Avatar answered Oct 05 '22 14:10

Jeroen


Please use the "thread_settings" endpoint "https://graph.facebook.com/v2.6/me/thread_settings" as your API endpoint.

You are using the messages endpoint.

like image 21
Rupul Safaya Avatar answered Oct 05 '22 16:10

Rupul Safaya