Hi all,
I'm using LWP::UserAgent to post JSON data to a php script. It's working fine on my Debian machine, but from Windows XP/ActiveState Perl, the post data isn't sent.
$req=$ua->post($myurl,
[$postcontent],
@netscape_like_headers,
'Content-Type' => 'application/json; charset=utf-8'
);
$postcontent is a string, something like:
{"slv":{"__type":"Presenters.JCMII.Views.SendLetterView","SelectedItem
+Ids":[1,2,3]}}
When I watch what is being sent with Ethereal/Wireshark, it all looks correct, and works fine: I see the application/json content header, the correct content-length, then \r\n\r\n followed by the post data.
On XP, I see a content-length of zero, and no posted data.
Both machines are running Perl 5.10.0. The XP machine has LWP::UserAgent 5.826, Linux machine 5.810
The script is identical on both machines, and I've checked for silly errors (like $postcontent being empty).
Any ideas what could be causing this? Is it anything to do with the posted data not being in the more common key=value format?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.