Note, you'll want to learn the <code> tag when posting code on perlmonks.

So you want to translate this curl command into Rest::Client code, right?

curl -X POST \ -H "Content-Type: multipart/form-data" \ -H "ABC_APP_ID: <Application_ID>" \ -H "IABC_APP_PASSWORD: <Application_Password>" \ -F "deliverable_file=@sample.xml" \ -F "data_transaction_code=SOA" \ -F "file_name=RRR-xxxxxxxxxx.mmddyyyy-hhmmss.ext" \ -F "agency_task_order_parameter=12345667890" \ -F "contractor_service_request_number=123456780123456789" \ -F "deliverable_type=Notification" \ -F "data_transaction_file_date=2016-01-21" \ -F "tags=\"tagSample1\", \"tagSample2\"" \ "http://<server>:<port>/cdx/abc/gsa/deliverables"
should look something like:
#!/usr/bin/perl use strict; use warnings; use REST::Client; my $server = 'localhost'; my $port = '7999'; my $path = '/cdx/abc/gsa/deliverables'; my $application_id = '...'; my $application_password = '...'; my %fields = ( deliverable_file => "sample.xml", data_transaction_code => "SOA", file_name => "RRR-xxxxxxxxxx.mmddyyyy-hhmmss +.ext", agency_task_order_parameter => "12345667890", contractor_service_request_number => "123456780123456789" , deliverable_type => "Notification", data_transaction_file_date => "2016-01-21", tags => ["tagSample1", "tagSample2"] ); my $url = "http://$server:$port/cdx/abc/gsa/deliverables"; my $client = REST::Client->new({host => $url}); # add the headers '-H' lines $client->addHeader('ABC_APP_ID', $application_id); $client->addHeader('IABC_APP_PASSWORD', $application_password); # add the fields '-F' lines my $get_query = $client->buildQuery(%fields); #this doesn't help for +POST $client->POST($url);
Note: edited to remove the major code errors

In reply to Re: how to post an xml using REST::Client by spazm
in thread how to post an xml using REST::Client by KSHYAMKUMAR

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.