I got this error HTTP::Message content must be bytes when running my program (it uses WWW::Mechanize). Here is the code:

my $query = qq{ <root><post_form_data_action object_name="$object->{reference_ +name}" object_id="$object->{reference_id}" object_version="1" form_na +me="Bookmark" form_context="create" process_id="$object->{process_id} +" > <post_attribute_data attribute_name="SocialMediaAccount" >$acc +ount</post_attribute_data> <post_attribute_data attribute_name="Url" >$object->{url}</pos +t_attribute_data> <post_attribute_data attribute_name="Title" >$object->{title}< +/post_attribute_data> <post_attribute_data attribute_name="Content" >$object->{conte +nt}</post_attribute_data> <post_attribute_data attribute_name="Tags" >$object->{tags}</p +ost_attribute_data> <post_attribute_data attribute_name="Status" >$object->{status +}</post_attribute_data> <post_attribute_data attribute_name="Category" ></post_attribu +te_data> </post_form_data_action> </root> }; $mech->post( $CONFIG{BASE_URL} . "/synnd/webif.awr?undefined", Con +tent => $query );

This error occurs only on few results but it's very weird. I look into $query and it's looks like containig only ASCII. I save $query value to the file with:

open my $error, ">", "error.txt" or die $!; print $error $query; close $error;

Here is $query which produce the error:

<root><post_form_data_action object_name="Buzz" object_id="-23 +789858" object_version="1" form_name="Bookmark" form_context="create" + process_id="92381" > <post_attribute_data attribute_name="SocialMediaAccount" >Soci +alMediaAccount:1592361</post_attribute_data> <post_attribute_data attribute_name="Url" >http://myselfdevelo +pment.net/index.php/2007/05/09/how-to-blow-your-mind-the-10th-dimensi +on/</post_attribute_data> <post_attribute_data attribute_name="Title" >How To Blow Your +Mind: The 10th Dimension SAVE </post_attribute_data> <post_attribute_data attribute_name="Content" >Ok.. the first +time I viewed this, I thought this would be easy… from the 1st dimens +ion to the 2nd and so on… my brain fried around the 5th and sixth dim +ension… never mind the 10th dimension.</post_attribute_data> <post_attribute_data attribute_name="Tags" >science,video,phys +ics,dimensions,mathematics</post_attribute_data> <post_attribute_data attribute_name="Status" >New</post_attrib +ute_data> <post_attribute_data attribute_name="Category" ></post_attribu +te_data> </post_form_data_action> </root>

What's wrong with my data? How i can fix this error?


In reply to Error "HTTP::Message content must be bytes" while posting with LWP by Gangabass

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.