How to test that data source is returning data from LightDB State

Hello,
I have a device publishing data to Golioth LightDB State. The expected data is being updated correctly every minute.

Now, I want to confirm that the data source is returning data correctly using, for example, websocat.

LightDB State:

Screen Shot 2023-05-31 at 11.02.09 PM

When I use websocat and let it run for ~5 minutes, I don’t see any data being retrieved. I do see the LightDB State get updated every minute.

What am I doing incorrectly? Thank you.

$ websocat wss://api.golioth.io/v1/ws/projects/aqw1066/devices/mydeviceid/env/voc?x-api-key={myapikey}

{“code”:5,“message”:“Not Found”,“details”:[]}

Hi @zpm1066! Welcome to Golioth and thanks for your question. I believe your endpoint needs to be updated to include /data/ between /mydeviceid/ and /env/. Your full URL would be:

wss://api.golioth.io/v1/ws/projects/aqw1066/devices/mydeviceid/data/env/voc?x-api-key={myapikey}

Could you give that a try and see if it works for you?

Reference: LightDB | Golioth

Hi @hasheddan
Actually, I tried data/ in the path as well earlier but got the following error.

$ websocat wss://api.golioth.io/v1/ws/projects/aqw1066/devices/mydeviceid/data/env/voc?x-api-key={myapikey}
{“error”:{“code”:7,“message”:“failed to check permissions to access/modify this resource: user not allowed to call method”,“details”:[]}}

@zpm1066 I see. That is the correct endpoint, are you certain that the API key being used is from the same project that the device is in?

@hasheddan,
Yes, I only have one API key setup.

projectid

Screen Shot 2023-05-31 at 11.52.27 PM

wss://api.golioth.io/v1/ws/projects/aqw1066/devices/643c620df272169b4557ee61/data/env/voc?x-api-key={myapikey}
{“error”:{“code”:7,“message”:“failed to check permissions to access/modify this resource: user not allowed to call method”,“details”:[]}}

@zpm1066 just to make sure, do the following steps accurately reflect how you obtained the API key:

  1. Go to console.golioth.io.
  2. Go to project aqw1066.
  3. Go to Project Settings > API Keys.
  4. Ensured the Type of the listed key is API_KEY.
  5. Copied the hidden value, then used it as the ?x-api-key value.

A few helpful notes:

  • Make sure your API key is not surrounded by {} in the URL. (i.e. if your API key is coolkey123 then the URL should have ?x-api-key=coolkey123 not ?x-api-key={coolkey123} . See Authentication | Golioth for an example)
  • Make sure you are using a key of type API_KEY and not JWT_KEY.

Hi @hasheddan,

Wonderful! I had the API key within {} in the URL. My bad! thank you.

websocat wss://api.golioth.io/v1/ws/projects/aqw1066/devices/643c620df272169b4557ee61/data/env?x-api-key=myapikey

{"result":{"data":{"hum":36,"pm25":0,"temp":26,"voc":233}}}

{"result":{"data":{"hum":36,"pm25":0,"temp":26,"voc":241}}}

{"result":{"data":{"hum":36,"pm25":0,"temp":26,"voc":239}}}

No worries @zpm1066! Glad we got it working!

@hasheddan ,

Thanks. Now, I should be able to chart the LightDB State data in Grafana.

I’ll update you once I get the Grafana Dashboard charting the sensor data.

1 Like