Question

I want to do:

 curl -X DELETE -d '{"name":"flowx"}' 'http://somewhere/wm/staticflowentrypusher/json'

In perl:

 my $browser = LWP::UserAgent->new;
 my $url = 'http://somewhere/wm/staticflowentrypusher/json';
 $browser->delete($url, '{"name":"flowx"}');

But I get:

 Illegal field name '{"name":"flowx"}' at /home/user/perl5/lib/perl5/HTTP/Request/Common.pm line 115
Was it helpful?

Solution

Arguments in LWP::UserAgent::delete() are used to create headers not content. Use HTTP:Request for that:

my $browser = LWP::UserAgent->new;
my $url = 'http://somewhere/wm/staticflowentrypusher/json';

my $req = HTTP::Request->new(DELETE => $url);

$req->content('{"name":"flowx"}');
my $response = $browser->request($req);

say $response->content;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top