我有以下curl命令可以使用。
curl -X POST -H“Content-Type:application / json”-H“username:” - H“password:” - data'{“serviceName”:“FIND_CHNGE”,“keyValues”:{“taskId “:”CHNGE17110462“,”网站“:”测试“}}'http://traceqa.vip.qa.ebay.com/arsys/rest/service/findTicket
然而,当我转换为mech获取内部服务器错误,无法发布。
#!/usr/bin/env perl
use warnings;
use strict;
use URI::Escape;
use lib './lib';
use Utils::PipeJSON;
use Data::Dumper;
use IO::CaptureOutput qw/capture_exec/;
use JSON;
use WWW::Mechanize;
my %output;
my $mech = WWW::Mechanize->new(keep_alive=>1);
$mech->ssl_opts(verify_hostname => 0)
my $resp;
my $issueurl = "http://traceqa.vip.qa.ebay.com/arsys/rest/service/findTicket";
my $json1 = '{"serviceName:"FIND_CHNGE","keyValues":{"taskId":"CHNGE17110462","site":"test"}}';
print STDERR "$json1";
$mech->add_header( 'username' => '<username>' );
$mech->add_header( 'password' => '<password>' );
$mech->add_header( 'Content-Type' => 'application/json' );
eval {
$resp = $mech->post($issueurl, Content=>$json1, "Content-type" => 'application/json');
};
请帮忙看看可能出现什么问题?