我正在使用lwp::useragent来对抗salesforce rest。
我必须使用http修补程序请求。
对于get和post请求,我们使用以下代码:
要求LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $get_response = $ua->get('http://search.cpan.org/',x=>'y');
my $post_response = $ua->post('http://search.cpan.org/',x=>'y');
不幸的是这不起作用。
my $patch_response = $ua->patch('http://search.cpan.org/',x=>'y');
我不知道如何使用这个模块。
这个问题有一个解决办法,如这里所解释的,How do I send a request using the PATCH method for a Salesforce update?
这是可行的,但这不是一个好的解决方案。
我发现使用python可以显式地对请求进行How do I make a PATCH request in Python?补丁,因此我假设perl也有一个选项。
发布于 2014-05-28 12:04:49
my $request = HTTP::Request->new(PATCH => $url);
... Add any necessary headers and body ...
my $response = $ua->request($request);
发布于 2017-07-23 12:03:42
这件事最近变得容易多了。PATCH
现在在HTTP::Message
中实现(如POST
)。
首先,更新HTTP::Message
模块(到6.13或更高版本)。
然后
my %fields = ( title => 'something', body => something else');
my $ua = LWP::UserAgent->new();
my $request = HTTP::Request::Common::PATCH( $url, [ %fields ] );
my $response = $ua->request($request);
https://stackoverflow.com/questions/23910962
复制相似问题