Hi , I am trying to interface witha a server which accepts multipart/mixed content type.I am using REST::client to send a post request and the content is created using the MIME::Entity module. However when i try to post , I am getting a 500 Not a scalar reference error. Not sure how to post with a scalar variable. my code :
sub uploadCodeCoverageZip { # Verify everything and if it checks out call the WSDL. Otherwise just + return error my $self = shift(); my $ret = "Unknown Error\n"; # get an xml from xml::simple my $ws_request = createCodeCoverageObject( password => $self->{password}, coverageType => $self->{coverageType}, buildVersion => $self->{buildVersion}, testPlanId => $self->{testPlanId}, loginId => $self->{loginId}, cloverFilePath => $self->{cloverFilePat +h}, ); my $multipart = MIME::Entity->build(Type => "multipart/mix +ed"); # this might work but gives a Not a scalar reference when used + as request content my $url = 'http://someserver.com/path/to/ws'; '#'my server my $ua = LWP::UserAgent->new; my $h = HTTP::Headers->new; my $file = '/etc/passwd'; # Name the file open(INFO, $file); # Open the file my @lines = <INFO>; # Read it into an array close(INFO); $h->header('Content-Type' => 'multipart/mixed', Accept=>'appli +cation/json','Cookie', $by->{cookie},'User-Agent', $self->getUserAgen +t()); my @ws_result_array = (); # approximating the post request push (@ws_result_array, '--Boundary'); push (@ws_result_array, $ws_request); push (@ws_result_array, '--Boundary'); push (@ws_result_array, @lines); my $GetReq = HTTP::Request->new( 'POST', $url, $h, @ws_result_array // not sure what to put here ); print $GetReq->as_string; my $resp = $ua->request($GetReq); print $resp->decoded_content; return "eod"; }
the above code returns a request syntactically incorrect response from server I have tried attaching objects to the multipart object but that gives a not a scalar reference error. do let me know if you need nething thnx help is much appreciated. thanks

In reply to perl client with multipart/mixed content by bbarodia

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.