gpt4 book ai didi

lwp - 没有命名参数的 REST HTTP DELETE

转载 作者:行者123 更新时间:2023-12-02 04:55:36 24 4
gpt4 key购买 nike

我想做的事:

 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

最佳答案

LWP::UserAgent::delete() 中的参数用于创建标题而不是内容。为此使用 HTTP:Request:

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;

关于lwp - 没有命名参数的 REST HTTP DELETE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18056216/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com