JSON format for TIMESTORE posts?

Hi folks,

Can skip down past this first bit - made some progress but still cannot post data - I will leave this thread intact for other with the same question.

----------------------------------------------------------------------------------------------------------------------------------

Sorry, really basic questions here - just attempting to get EMONCMS running on a remote server for the first time without luck yet and wondered if I can ask you good folk for some advice :-)

When I open a socket should it be to: "http://mydomain.com/emoncms/input/" ?

How would I find out which port to open?  Have tried 21 & 80 ?

I have formatted my JSON string as per below for multiple values but how would I add in a NODE ID for these values?

post.json?json={CO2:450},{TEMP:19.54},{RH:58.32}&apikey=xxxxxxxxxxxxxxxxxxx

Thanks for any pointers.

 

robur's picture

Re: JSON format for TIMESTORE posts?

Hello again,

Getting there :-)

I have now managed to open a socket at "mydomain.com" with port number 80.

Now trying to get the send to work, I'm sending this string but without success..... any clues as to what I'm doing wrong?

emoncms/api/post.json?json={CO2:380},{Temperature:21.29},{RH:55.1344},{DP:11.9837}&apikey=xxxxxxx

Cheers.

robur's picture

Re: JSON format for TIMESTORE posts?

Hmmmm, a bit stuck now - tried lots of different ways of sending the data..... is something like this correct?

"GET /api/post?apikey=xxxxxxxxxxxxxx"
"&node=0"
"&json={CO2:450} HTTP/1.1"
"Host: mydomain.com"
"User-Agent: MCU"
"Content-Type: application/json"

robur's picture

Re: JSON format for TIMESTORE posts?

Forgot to say that the Engine I'm using is TimeStore on EMONCMS V6  :-)

robur's picture

Re: JSON format for TIMESTORE posts?

Battling on but still not there - I am getting a 200 response now though but still no data coming through.

Current attempt looks like this:

"POST /emoncms/input/post.json?apikey=xxxxxxxxxxxxxxxx HTTP/1.1"
"Host: mydomain.com"
"Content-Length: (string length)"
"Content-Type: application/json"
"{CO2:450}"
 

Any pointers would be FAB :-)

robur's picture

Re: JSON format for TIMESTORE posts?

Wow - it works.

This was my post in the end:

"POST /emoncms/input/post.json?json={CO2:455}&apikey=xxxxxxxxxxxxxxxxxxxxxxxx HTTP/1.1"
"Host: mydomain.com"
"User-Agent: MCU"
"Content-Length: (datalength)"
"Content-Type: application/json"
 

Hope these personal ramblings help someone somewhere :-)

robur's picture

Re: JSON format for TIMESTORE posts?

OK, so not done yet.

The FEEDS are showing as UPDATED but I'm still missing something as the POST process takes some 20 seconds, the server doesn't respond with a 200 code (or any other code for that matter) and there is nothing to see in the VIS section.

Hmmmm, its been a long day.

Any ideas to complete this code and get it working properly are appreciated :-)

robur's picture

Re: JSON format for TIMESTORE posts?

OkiDoki,

Seems like this has to be a GET rather than a POST?

"GET /emoncms/input/post.json?json={CO2:455}&apikey=xxxxxxxxxxxxxxxxxxxxxxxx HTTP/1.1"

Works for now :-)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.