Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I want to send 2 different files to an API. File-1 contains XML data and File-2 is a MS word document. I am using following code:

my $signedURL = ‘signedURL'; my $file = ‘C:\some.docx'; my $text = read_file( ‘C:\some.xml’ ) ; my $ua = LWP::UserAgent->new; my $req = $ua->request(PUT $signedURL, Content_Type => ‘form-data’, Content => [ XML => $text, Upload => [“$file”] ] ); print “\nRESPONSE — \n” . $req->as_string; # Check the outcome of the response if ($req->is_success) { print $req->content; } else { print “\n in else not success\n”; }

It is generating following error:

Not a SCALAR reference at C:/Dwimperl/perl/vendor/lib/HTTP/Message.pm +line 156. at C:/Dwimperl/perl/vendor/lib/HTTP/Message.pm line 156 HTTP::Message::add_content(‘HTTP::Request=HASH(0x34f4f54)’, ‘ARRAY(0x3 +4e 84bc)’) called at C:/Dwimperl/perl/vendor/lib/HTTP/Request/Common.pm l +ine 108 HTTP::Request::Common::_simple_req(undef, undef, undef, undef) called +at C:/Dwimperl/perl/vendor/lib/HTTP/Request/Common.pm line 22 HTTP::Request::Common::PUT(‘http://api.aspose.com/v1.1/words/executeMa +il Merge?withRegions…’, ‘Content_Type’, ‘form-data’, ‘Content’, ‘ARRAY(0x +34e84bc) ‘) called at word_multipart2.pl line 50 Press any key to continue . . .

Please, guide


In reply to PUT a Multipart request in PERL by xpert

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found