Hoping i can get some help.. Trying to get the http::request working for multipart form data I am attempting to submit files through a multipart/form-data here is the code
my $reg = HTTP::Request->new("POST"=>"https://$server/upload"); $reg->content_type("multipart/form-data"); $reg->header("X-Update-Nonce"=>$nonce); $reg->content([ 'label'=>'TestFile.pdf', 'file'=>['test.pdf'] ]); print "REQUEST\n".$reg->as_string();

A couple of problems, i have to use the header multipart/form-data or else the server returns an error. Where the documentation for http::request::common says to use content-type of form-data alone? (content_type('form-data') vs ('multipart/form-data'))

If i just use "form-data" i get a 400 Bad Request, the header has to be multipart/form-data

When i print out the Request it isn't converting the "Content" correctly, it is printing out the Array Ref instead. I've tried to format the content different ways but none of them have produced what i need. In the documentation of HTTP::Request it specifies that content is a string of bytes.. I'm not sure what they are referring too, i haven't been able to get any of the example code in the documentation to work like it should.

This is what i prints out

POST https://xxxxx/upload Content-Type: multipart/form-data X-Update-Nonce: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ARRAY(0x9dec0d8)

The array is where the content is suppose to be but i haven't gotten it to fill out correctly yet.

Any Ideas? - Thanks


In reply to multipart/form-data content problem by H-street

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.