in reply to Re^2: Need help with sending xml formatted payload using HTTP::Request
in thread Need help with sending xml formatted payload using HTTP::Request

Hmm .. try adding :
$req->header('Accept' => 'application/xml');
since, by default, apparently the accept list is empty, and altassian REST used by bamboo seems to require it.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

  • Comment on Re^3: Need help with sending xml formatted payload using HTTP::Request
  • Download Code

Replies are listed 'Best First'.
Re^4: Need help with sending xml formatted payload using HTTP::Request
by drohr (Acolyte) on Jan 26, 2015 at 20:43 UTC
    I gave that a try and it still didn't work.. I got the same error message: "The server refused this request because the request entity is in a format not supported by the requested resource for the requested method."

      I think perhaps there was a confluence of almost right in the advice, try this mix (default auth headers like I showed before are more convenient because you only do it once)–

      use strict; # Never- use warnings; # -skip these. use LWP::UserAgent; my $urlRequest = "http://bamboohost/rest/api/latest/result/projectname +-planname-latest/label"; my $xml = <<''; <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <label name="testlabel"/> my $ua = LWP::UserAgent->new; my $post = HTTP::Request->new( POST => $urlRequest ); $post->authorization_basic("username", "password"); $post->content($xml); $post->content_type("application/xml"); print $post->as_string; my $result = $ua->request( $post );
        this worked !! changing 'text' to 'application' on this line fixed it.
        $post->content_type("application/xml");
        thanks for all the help, everyone!