packetstormer has asked for the wisdom of the Perl Monks concerning the following question:
Hello
I am struggling converting a known working curl command (below) to a perl script. The curl command is first with my attempt following but I keep getting a 403 permission denied, even though curl works
curl -H "Authorization: PASSWORD" -H "Content-Type: application/json" + -d '{"message":"Test message"}' https://myurl.url.url/api/v1/action +s/message/
perl attempt
use LWP::UserAgent; use strict; my $url=" https://myurl.url.url/api/v1/actions/message"; my $ua = LWP::UserAgent->new; my $response = $ua->post($url, 'Content-type' => 'application/json', 'Authorization' => 'PASSWORD', 'data' => {"message":"Test message"} ); print $response->as_string;
Pointers welcome!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: curl to perl POST
by choroba (Cardinal) on Jan 25, 2019 at 14:18 UTC | |
Re: curl to perl POST
by hippo (Archbishop) on Jan 25, 2019 at 14:24 UTC | |
Re: curl to perl POST
by karlgoethebier (Abbot) on Jan 25, 2019 at 14:20 UTC |