Bad Request with expressjs+Node.js


#1

I’m using Node.js with ExpressJS framework. When I try to add a HTTP Destination here - https://datasift.com/destination/new/http - it keeps on giving me “The endpoint returned a 400 status” error in red box.

My expressjs app logs this error -
Bad Request: Bad Request
at next (/home/flip/www/flipapp/node_modules/express/node_modules/connect/lib/proto.js:125:13)
at module.exports (/home/flip/www/flipapp/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:54:23)
at IncomingMessage.module.exports (/home/flip/www/flipapp/node_modules/express/node_modules/connect/lib/middleware/json.js:74:60)
at IncomingMessage.EventEmitter.emit (events.js:93:17)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at Socket.socket.ondata (http.js:1825:22)
at TCP.onread (net.js:404:27)

I’ve very simple routes (coffeescript) -

app.get ‘/datasift/twitter_api’, (req, res) ->
console.log req
res.send ‘get test’

app.post ‘/datasift/twitter_api’, (req, res) ->
console.log req
res.send ‘post test’

console.log doesn’t get triggered in POST request but when i visit it via browser or send POST request via curl it works fine.

Can someone help me out ? I think it’s a bad bug with DataSift.


#2

When saving a Data Destination, the system will attempt to POST an empty JSON object to the endpoint. What does "curl -X POST -H 'Content-Type: application/json' your_url" return?


#3

Thanks for responding. The curl commands returns ‘post test’ in the command line while datasift still gives the error!