Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling PUT on /devices/:id does not appear to update database #15

Closed
deadprogram opened this issue Feb 19, 2014 · 4 comments
Closed

Calling PUT on /devices/:id does not appear to update database #15

deadprogram opened this issue Feb 19, 2014 · 4 comments

Comments

@deadprogram
Copy link
Contributor

I created a test object in the database, then tried to update it. The call appears to succeed, however subsequent calls did not appear to persist the data. Here is my command line:

$ curl -X PUT -d "awesome=sauce" http://localhost:3000/devices/18676eb1-9997-11e3-8c2a-f18a07a72684
{"uuid":"18676eb1-9997-11e3-8c2a-f18a07a72684","awesome":"sauce","timestamp":1392839514415,"eventCode":401,"_id":"53050b5ae17ed4012e00000f"}
$ curl -X GET http://localhost:3000/devices/18676eb1-9997-11e3-8c2a-f18a07a72684
{"_id":"5304fd9d71d92a5025000001","channel":"main","color":"black","online":true,"socketId":"X3vYDIdBC5xGf_vOoAbV","timestamp":1392838789634,"type":"drone","uuid":"18676eb1-9997-11e3-8c2a-f18a07a72684","eventCode":500

Looking at my local skynet log, it would appear no errors occurred, even tho the data was not saved:

Device udpated: {"uuid":"18676eb1-9997-11e3-8c2a-f18a07a72684","awesome":"sauce","timestamp":1392839514415}
{ uuid: '18676eb1-9997-11e3-8c2a-f18a07a72684',
  awesome: 'sauce',
  timestamp: 1392839514415,
  eventCode: 401,
  _id: 53050b5ae17ed4012e00000f }
Event Loggged: {"uuid":"18676eb1-9997-11e3-8c2a-f18a07a72684","awesome":"sauce","timestamp":1392839514415,"eventCode":401,"_id":"53050b5ae17ed4012e00000f"}
Log file udpated
   debug - emitting heartbeat for client X3vYDIdBC5xGf_vOoAbV
   debug - websocket writing 2::
   debug - set heartbeat timeout for client X3vYDIdBC5xGf_vOoAbV
   debug - got heartbeat packet
   debug - cleared heartbeat timeout for client X3vYDIdBC5xGf_vOoAbV
   debug - set heartbeat interval for client X3vYDIdBC5xGf_vOoAbV
18676eb1-9997-11e3-8c2a-f18a07a72684
Device whoami: {"_id":"5304fd9d71d92a5025000001","channel":"main","color":"black","online":true,"socketId":"X3vYDIdBC5xGf_vOoAbV","timestamp":1392838789634,"type":"drone","uuid":"18676eb1-9997-11e3-8c2a-f18a07a72684"}
{ _id: 5304fd9d71d92a5025000001,
  channel: 'main',
  color: 'black',
  online: true,
  socketId: 'X3vYDIdBC5xGf_vOoAbV',
  timestamp: 1392838789634,
  type: 'drone',
  uuid: '18676eb1-9997-11e3-8c2a-f18a07a72684',
  eventCode: 500 }
Event Loggged: {"_id":"5304fd9d71d92a5025000001","channel":"main","color":"black","online":true,"socketId":"X3vYDIdBC5xGf_vOoAbV","timestamp":1392838789634,"type":"drone","uuid":"18676eb1-9997-11e3-8c2a-f18a07a72684","eventCode":500}
Log file udpated

Any thoughts?

@octoblu
Copy link
Collaborator

octoblu commented Feb 19, 2014

You should have received a 401 not authorized response since you didn't pass the token on the request. Looking into this now...

@octoblu
Copy link
Collaborator

octoblu commented Feb 19, 2014

It looks like it works if you include your token:

curl -X PUT -d "awesome=sauce&token=gquid3fv7uys0pb981h8tewitumu0udi" http://skynet.im/devices/eccce711-99a2-11e3-ae08-ff6ac0f6a82e

{"uuid":"eccce711-99a2-11e3-ae08-ff6ac0f6a82e","awesome":"sauce","timestamp":1392841973780,"eventCode":401,"_id":"530514f5e11d49b2330000e4"}

curl http://skynet.im/devices/eccce711-99a2-11e3-ae08-ff6ac0f6a82e

{"_id":"53051176e11d49b23300003d","appName":"skynetDemo","awesome":"sauce","channel":"main","online":false,"socketId":"JIn2CPl0iJG5hJX6yTTh","timestamp":1392841973780,"uuid":"eccce711-99a2-11e3-ae08-ff6ac0f6a82e","eventCode":500}p

@octoblu
Copy link
Collaborator

octoblu commented Feb 19, 2014

I also received an error on my call without a token but it was a 404 instead of a 401:

curl -X PUT -d "awesome=nada" http://skynet.im/devices/eccce711-99a2-11e3-ae08-ff6ac0f6a82e

{"error":{"message":"Device not found or token not valid","code":404},"timestamp":1392842098764,"eventCode":401,"_id":"53051572e11d49b2330000e5"}

@octoblu
Copy link
Collaborator

octoblu commented Mar 17, 2014

Token is required to update device.

@octoblu octoblu closed this as completed Mar 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant