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

I have tried that, but I get the same error.
  • Comment on Re^2: Need help with sending xml formatted payload using HTTP::Request

Replies are listed 'Best First'.
Re^3: Need help with sending xml formatted payload using HTTP::Request
by NetWallah (Canon) on Jan 21, 2015 at 17:06 UTC
    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

      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 );