I'am trying to post a value to emoncms using a perl script but i always got the error :
Received reply: {"success":false,"message":"Username or password empty"}
when i use the url in my browser like :
http://xxx/emoncms/input/post.json?node=1&json={power:200}&apikey=xxx
it works but when i try using a perl script it won't do a thing.
My code looks like that :
my $ua = LWP::UserAgent->new;
my $server_endpoint = "http://xxx/emoncms/input/post.json";
# set custom HTTP request header fields
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('Authorization' => 'Bearer xxx);
# add POST data to HTTP request body
my $post_data = '{"node": "1", "json": "{power:219}", "apikey": "xxx"}';
$req->content($post_data);
my $resp = $ua->request($req);
I tried with and without the header authorisation, same thing in the end.
Anyone with perl experience or an idea on why this don't works ?
Re: POST request using perl
Can you echo out the response from emoncms? or see the completed request made by the script?