我正在尝试使用使用多部分实体的 API。我想我缺少一些东西。
我目前的代码如下:
#!/usr/bin/perl
#$request = $ua->request($request);
#my $results=$ua->request($request);
$content = $request->content;
#print "Content-type: application/xml\n\n";
print $content;
exit;
您必须将要创建的内容类型添加到 POST 的参数中,并提供文件名作为数组引用。这应该有效:
my $request=(POST 'http://servername/test.jsp',
Content_Type => 'form-data',
Content => [
appGUID => "Test",
userId => "User",
password => "<Password>",
bugId => "12345678",
fileDescription => "trying to attach a file",
external => "false",
Filedata => [ "Path" ],
],
);