07-20-2016 13:50
07-20-2016 13:50
Hi, I'm new to fitbit api, I configured the endpoint in my server to receive notifications and now I'm getting them, I get notifications like these:
{ updates: [ { fieldName: 'updates', originalFilename: 'update1469047095888.json', path: '/tmp/Skt92qATbUsLYIOMpNhrgy--.json', headers: { 'content-disposition': 'form-data; name="updates"; filename="update1469047095888.json"', 'content-type': 'application/json', 'content-transfer-encoding': 'binary' }, size: 107 } ] }
so I know that a user just uploaded some data.
My question is how do I get that data? or that Json file that is generated?
any help will be appreciated!
Answered! Go to the Best Answer.
07-20-2016 14:31
07-20-2016 14:31
the issue was that I set in https://dev.fitbit.com/apps/edit the endpoint as JSON files and not JSON Body
07-20-2016 13:58
07-20-2016 13:58
Not sure I understand correctly but that doesn't seem like a correct Fitbit Notification message.
You should see something like this:
[ { "collectionType":"foods", "date":"2010-03-01", "ownerId":"228S74", "ownerType":"user", "subscriptionId":"1234", }, { "collectionType":"foods", "date":"2010-03-02", "ownerId":"228S74", "ownerType":"user", "subscriptionId":"1234", }, { "collectionType":"activities", "date":"2010-03-01", "ownerId":"184X36", "ownerType":"user", "subscriptionId":"2345", }
You can check the documentation here: https://dev.fitbit.com/docs/subscriptions/#example-notifications
07-20-2016 14:04
07-20-2016 14:04
mmm weird, I'm using node and when I parse the req.body is empty ({}).
the only way that I get data is using https://www.npmjs.com/package/multiparty#readme, to parse http requests with content-type multipart/form-data.
the data that I get is the one I posted below
07-20-2016 14:31
07-20-2016 14:31
the issue was that I set in https://dev.fitbit.com/apps/edit the endpoint as JSON files and not JSON Body