Hello Monks
I have an odd problem that I can't seem to resolve involving LWP::UserAgent. I am trying to pass a simple POST to a URL. The URL requires certain fields and has a date type of "array".
To do this, in Curl, say, I wrap the value(s) in square brackets []. However, when I do this in LWP::UserAgent the sqaure bracket gets encoded and the POST fails!
Does anyone know how to pass a content field in LWP::UserAgent and keep the string exactly as is?
e.g - entities value is the problem. Curl first (works).
curl -X POST "https://mysite.com/lookup" \ -d '{"name":"respond", "falvour": green, "location": europe, "enti +ties":[369662]}' \ -H "Content-Type: application/json"
LWP::UserAgent example (failing)
my $ua = LWP::UserAgent->new; $ua->default_header('Content-Type' => 'application/json'); $data = { name => "responding", flavour => "green", entities => '[369662]' , location => "europe", }; my $response = $ua->post( 'https://mysite.com/lookup', $data
The latter results in the string being passed as "....&entities=%5B369662%5D", which gets rejected.
In reply to LWP content literal string by packetstormer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |