context:
my first project cosm recording datapoints electric meter. when @ graph of feed, it's flatlined @ 0 though datapoints appear correctly received.
any idea what's wrong, or things should in order debug it?
more info:
when debug feed, see receiving approximately 8 api requests per minute expected.
here's instance of received datapoint viewed cosm's 'debug feed' interface. note in particular response 200 [ok], , request body has sensible timestamp , non-zero value:
200 post /api/v2/feeds/129722/datastreams/1/datapoints 06-05-2013 | 08:16:54 +0000 request headers version http/1.0 host api.cosm.com x-request-start 1367828214422267 x-apikey <expunged> accept-encoding gzip, deflate, compress accept */* user-agent python-requests/1.2.0 cpython/2.7.3 linux/3.6.11+ origin request body {"at": "2013-05-06t08:16:57", "value": 164.0} response headers x-request-id 245ee3ca6bd99efd156bff2416404c33f4bb7f0f cache-control max-age=0 content-type application/json; charset=utf-8 content-length 0 response body [no body]
update
even though docs specify json default, explicitly added ".json" post url (/api/v2/feeds/129722/datastreams/1/datapoints.json
) didn't appear make difference.
update 2
i enclosed "value" value in strings, request body reads (for example):
{"at": "2013-05-06t15:37:06", "value": "187.0"}
still behaving same: see updates in debug view, zeros reported in graph view.
update 3
i tried looking @ data using api rather cosm-supplied graph. guess datapoints not being stored reason (despite 200 ok return status). if put url in web browser:
http://api.cosm.com/v2/feeds/129722.json?interval=0
i in response:
{"id":129722, "title":"rainforest automation raven", "private":"false", "tags":["power"], "feed":"https://api.cosm.com/v2/feeds/129722.json", "status":"frozen", "updated":"2013-05-06t05:07:30.169344z", "created":"2013-05-06t00:16:56.701456z", "creator":"https://cosm.com/users/fearless_fool", "version":"1.0.0", "datastreams":[{"id":"1", "current_value":"0", "at":"2013-05-06t05:07:29.982986z", "max_value":"0.0", "min_value":"0.0", "unit":{"type":"derivedsi","symbol":"w","label":"watt"}}], "location":{"disposition":"fixed","exposure":"indoor","domain":"physical"} }
note status listed "frozen" (last update received > 15 minutes ago) despite fact debug tool showing 7 or 8 updates per minute. datapoints going?
resolved. @calum @ cosm.com support kindly pointed out, wasn't sending formed request. sending following json:
{"at": "2013-05-06t08:16:57", "value": 164.0}
when should have sending:
{ "datapoints":[ {"at": "2013-05-06t08:16:57", "value": 164.0} ] }
calum points out batch several points @ time cut down number of transactions. i'll that, now, suffice fixing body of request made start working.
Comments
Post a Comment