Gangabass has asked for the wisdom of the Perl Monks concerning the following question:

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?

Replies are listed 'Best First'.
Re: Error "HTTP::Message content must be bytes" while posting with LWP
by Anonymous Monk on Nov 11, 2009 at 08:23 UTC

      Yes, i have read this but how i can fix the error?

        Two choices. From the above link:
        Seems the latest 'update' to libwww-perl broke things that used to work . . .

        Solution 1: downgrade libwww-perl to an older version.

        . . . this has to do with utf8 stuff in the content . . .

        Solution 2: make sure there's no "utf8 stuff in the content". Looking at your $query I see '...' a couple of times, not as three dots but as a single ellipsis character. Try changing those first; if no joy then keep searching for non-ASCII characters.