2013-08-05 43 views
0

我想做的事:REST HTTP DELETE沒有命名的參數

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

在Perl中:

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

,但我得到:

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

回答

3

參數在LWP :: UserAgent的:: delete()用於創建標題而不是內容。使用HTTP:請求:

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;