尝试从脚本发送POST
请求时出现错误:perl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->credentials($netloc,$realm,$username,$password);
use HTTP::Request::Common;
my $req = HTTP::Request::Common::POST($url,'content' => $conf);
$req->as_string()
是
POST http:.....
Content-Length: 31003
Content-Type: application/x-www-form-urlencoded
.....&createTime=1361370652541¶meters=HASH(0x28fd658)¶meters=HASH(0x28fd670)¶meters=HASH(0x28fd6e8)¶meters=HASH(0x28fd760)&nodes=32&.....&alerts=HASH(0x632d00)&alerts=HASH(0x245abd0)&.....
我得到的错误是
Unexpected character ('H' (code 72)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
这让我怀疑问题出在重复的
parameters=HASH(...)
和alerts=HASH(...)
元素上;相反,我想看到类似的东西
alerts=%5B%7B%22email%22%3A%22foo%40bar.com%22%2C%22type%22%3A%221%22%2C%22timeout%22%3A%22%22%7D%5D
$conf
是哈希引用,$conf->{"parameters"} and
$conf->{"alerts"}` 是数组引用(其元素是哈希引用)。
我究竟做错了什么?