This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signal k Webapi Upload
#1
Hi All

I've downloaded and installed the Signal K Web API plugin. (https://github.com/sbman/signalk-webapi-upload) It looks like a fantastic way of keeping our website updated with our position when sailing. 

However I wonder if anyone else uses the plugin? I'm having trouble getting it to work correctly.

The data is prepared by the plugin as an array of name/value pairs:



Code:
{
   path: [
       {"name":"lat","value":"59.7122406"},
       {"name":"lon","value":"24.7288183"},
       {"name":"depth","value":"12.779"}
   ]
}



Once the data is prepared from the list of items you want to send, it is passed to the handlebars.js template for processing.


Code:
[
   {{#each path }}
       {"N":"{{this.name}}","V":"{{this.value}}"}{{#unless @last}},{{/unless}}
   {{/each}}
]


This will output as the following:

Code:
[
   {"N":"lat","V":"59.7178682"},
   {"N":"lon","V":"24.733011"},
   {"N":"depth","V":"21.009"}
]

I can see the data hitting the page and return information back to the plugin but it looks like it's not sending any information in the first place?


The API endpoint is a PHP MVC app, which is basically echo'ing out what is being sent.



PHP Code:
<?php
  $body 
file_get_contents("php://input");
 
 var_dump($body);
?>
the plugin log is returning the following... (The Pi is not near my machine so outputting the mmsi as that is a piece of data I have


Sep 08 19:26:42 2022-09-08T18:26:42.161Z signalk-webapi-upload mmsi
Sep 08 19:26:42 2022-09-08T18:26:42.161Z signalk-webapi-upload Valid Type.
Sep 08 19:26:42 2022-09-08T18:26:42.169Z signalk-webapi-upload Template output: { "positions": [{"N":"test","V":"235004884"}]}
Sep 08 19:26:42 2022-09-08T18:26:42.170Z signalk-webapi-upload Headers: {"accept":"/","content-type":"application/json"}
Sep 08 19:26:42 2022-09-08T18:26:42.170Z signalk-webapi-upload Posting to: https://sailadventure.co.uk/automations/posit
Sep 08 19:26:42 2022-09-08T18:26:42.172Z signalk-webapi-upload Interval reached,value passed.
Sep 08 19:26:43 2022-09-08T18:26:43.786Z signalk-webapi-upload Result:200 M: OK
Sep 08 19:26:43 2022-09-08T18:26:43.793Z signalk-webapi-upload Server returned: string(0) ""
Sep 08 19:26:43 2022-09-08T18:26:43.793Z signalk-webapi-upload No error


It looks like something is missing from being sent to the page but I'm at a loss where I've gone wrong.

Is anyone using this successfully??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)