in reply to Re^2: HTTP::Request::Common output format.
in thread HTTP::Request::Common output format.

The module doesn't afford what you want but it's in there if you dig it out.

# Ewwwwwwwwwwww... print $client->{_res}->request->as_string, $/;

Replies are listed 'Best First'.
Re^4: HTTP::Request::Common output format.
by KSHYAMKUMAR (Acolyte) on Apr 14, 2016 at 21:53 UTC

    hmm, getting the below error ... Can't locate object method "as_string" via package "REST::Client" at rest_client.pl line 35. sorry i sent the above message a bit too early...

    i am getting the below values in the output, does it send the request body only if the POST is successful?? I only could see the header in the output at the moment.

    REST::Client=HASH(0x2615438)POST http://localhost:.../cdx/abc/gsa/deli +verables User-Agent: REST::Client/273 Content-Length: 0 Content-Type: form-data ABC-APP-ID: ... IABC-APP-PASSWORD: ...

      You cannot get that error from the code I offered.

      I haven’t played with REST::Client or used it and I wouldn’t. It’s the wrong candidate, in my view, for this kind of chained method stuff, its error handling is not ideal, and if you examine the source you’ll see that everything it’s doing is pretty straightforward while also being limited in arbitrary ways.

      I’ve written lots of mini-REST clients—usually for testing—using WWW::Mechanize + JSON + URI, and the HTTP:: family and that’s where I’d recommend looking. Although, in your case, since you’re using XML you may need XML::LibXML or XML::Twig or something. If the REST service can respond in JSON, I strongly recommend it over XML.

        may i request you for a sample code to send an xml with header and body content over to a REST server ??

        my requirement is to convert the below curl command into a REST webservice call to transfer sample.xml to the server.

        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"