fbsamples/messenger-platform-samples

Webhook cURL error

ladiesman1792 opened this issue · 10 comments

Hi, I did everything as instructions(https://developers.facebook.com/docs/messenger-platform/getting-started/webhook-setup) but I keep getting this error!
What did I do wrong?

Requesting side>>>

curl -H "Content-Type:application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}'

<title>Error</title>
SyntaxError: Unexpected token # in JSON at position 0
    at JSON.parse (<anonymous>)
    at createStrictSyntaxError (C:\Users\yshvc\messenger-webhook\node_modules\body-parser\lib\types\json.js:157:10)
    at parse (C:\Users\yshvc\messenger-webhook\node_modules\body-parser\lib\types\json.js:83:15)
    at C:\Users\yshvc\messenger-webhook\node_modules\body-parser\lib\read.js:121:18
    at invokeCallback (C:\Users\yshvc\messenger-webhook\node_modules\raw-body\index.js:224:16)
    at done (C:\Users\yshvc\messenger-webhook\node_modules\raw-body\index.js:213:7)
    at IncomingMessage.onEnd (C:\Users\yshvc\messenger-webhook\node_modules\raw-body\index.js:273:7)
    at emitNone (events.js:106:13)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1056:12)
curl: (6) Couldn't resolve host 'page,' curl: (6) Couldn't resolve host 'entry' curl: (3) [globbing] bad range specification in column 2 curl: (3) [globbing] bad range specification in column 2 curl: (3) [globbing] unmatched close brace/bracket in column 13

=====================================================

Node side>>>

SyntaxError: Unexpected token # in JSON at position 0
at JSON.parse ()
at createStrictSyntaxError (C:\Users\yshvc\messenger-webhook\node_modules\body-parser\lib\types\json.js:157:10)
at parse (C:\Users\yshvc\messenger-webhook\node_modules\body-parser\lib\types\json.js:83:15)
at C:\Users\yshvc\messenger-webhook\node_modules\body-parser\lib\read.js:121:18
at invokeCallback (C:\Users\yshvc\messenger-webhook\node_modules\raw-body\index.js:224:16)
at done (C:\Users\yshvc\messenger-webhook\node_modules\raw-body\index.js:213:7)
at IncomingMessage.onEnd (C:\Users\yshvc\messenger-webhook\node_modules\raw-body\index.js:273:7)
at emitNone (events.js:106:13)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)

Same issues as this post: #73

@ladiesman1792 Can you provide a link to your webhook code, either in a repo or gist?

Those are the files created following the manual. And there is node_modules directory created by Node.js promt with "npm install express body-parser" command.

@ladiesman1792 What are you using to send the cURL request? It appears that an unexpected character is being added.

@amuramoto

I enter this on cmd. Just like in the manual.

curl -H "Content-Type:application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}'

@ladiesman1792 Can you try typing it out instead of copy/paste?

Closing due to no response in 8 days.

any chance to reopen, I"m getting the same error

Yo!
Just delete the ' from the command line like this:
curl -H "Content-Type:application/json" -X POST "localhost:1337/webhook" -d '{"object": "page", "entry": [{"messaging": [{"message": "TEST_MESSAGE"}]}]}