Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:41:12+00:00 2026-06-16T00:41:12+00:00

I’ve got a perl script backing up our TeamCity server via the REST API

  • 0

I’ve got a perl script backing up our TeamCity server via the REST API as follows:

use strict;
use LWP::UserAgent;
use HTTP::Request::Common qw{ POST GET }

# ... code ommitted for brevity ... #

my $url = 'http://teamcity:8080/httpAuth/app/rest/server/backup';
my $req = POST( $url . '?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=' . $filename);   
$req->authorization_basic($username, $password);
my $resp = $ua->request($req);    

I tried posting the content more in line with the documentation for HTTP:Request, but for some reason it fails, complaining that I haven’t specified a file name:

# This fails
my $req= POST( $url, [ 'includeConfigs'   => 'true',
                            'includeDatabase'  => 'true',
                            'includeBuildLogs' => 'true',
                            'fileName'         => $filename, 
                          ] ); 

Yet, when I look at the backend REST log for TeamCity, the full request seems to have made it intact, and is identical to the one that passes above.

Log of successful command:

[2012-12-13 15:02:38,574]  DEBUG [www-perl/5.805 ] - rver.server.rest.APIController - REST API request received: POST '/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=foo', from client 10.126.31.219, authenticated as jsmith 

Log of failed command:

[2012-12-13 14:57:00,649]  DEBUG [www-perl/5.805 ] - rver.server.rest.APIController - REST API request received: POST '/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=foo', from client 10.126.31.219, authenticated as jsmith

Is there any other hidden difference between the two methods of making a POST request that could be causing the failure?

UPDATE: Here is the result of each request when printed via Data::Dumper

Successful POST:

$VAR1 = bless( {
             '_content' => '',
             '_uri' => bless( do{\(my $o = 'http://teamcity:8080/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=foo')}, 'URI::http' ),
             '_headers' => bless( {
                                    'content-type' => 'application/x-www-form-urlencoded',
                                    'content-length' => 0,
                                    'authorization' => 'Basic c3lzQnVpbGRTeXN0ZW1JOnBhaWQuZmFpdGg='
                                  }, 'HTTP::Headers' ),
             '_method' => 'POST'
           }, 'HTTP::Request' );

Unsuccessful POST:

$VAR1 = bless( {
             '_content' => 'includeConfigs=true&includeDatabase=true&includeBuildLogs=true&fileName=foo',
             '_uri' => bless( do{\(my $o = 'http://teamcity:8080/httpAuth/app/rest/server/backup')}, 'URI::http' ),
             '_headers' => bless( {
                                    'content-type' => 'application/x-www-form-urlencoded',
                                    'content-length' => 75,
                                    'authorization' => 'Basic c3lzQnVpbGRTeXN0ZW1JOnBhaWQuZmFpdGg='
                                  }, 'HTTP::Headers' ),
             '_method' => 'POST'
           }, 'HTTP::Request' );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:41:12+00:00Added an answer on June 16, 2026 at 12:41 am

    I think your server-side script can only handle GET parameters encoded in the URL, not POST data transmitted via standard intput. Note that there are several different methods described by HTTP, these are GET, POST, HEAD, DELETE etc. And then there are two ways of passing data to an application on the server. Most often one of those ways is also called GET parameters and the other one is called POST data because the GET parameters are usually used with the HTTP GET method and POST data is usually used for the HTTP POST method. However, they don’t have to. And I think you’re mixing up the HTTP POST method with GET parameters in the successful case and with POST data in the unsuccessful case.

    GET parameters are passed via the URL by, most often by appending ? to the URL followed by the actual key/value pais. Those are available via certain environment varialbes to the script running on the server. It’s up to the script to split the variables at the &, split key/value pairs on = and undo the escaping.

    For POST data the environment variable CONTENT_LENGTH tells the script how many bytes to read from its standard input. The actual key/value pairs are transmitted via a different encoding, usually as multipart encoded content. Yes, POST HTTP requests (mostly from HTML <form>s) can also be sent URL-encoded like GET parameters, but there’s a length limit imposed by the HTTP standard on the URLs including all parameters. Hence the method of transferring the data via standard input, and not via the URL.

    Now it looks like your server-side script can evaluate URL-encoded parameters (aka. GET parameters) parameters but not data posted to it via standard input. Even though you use the POST HTTP method/verb you don’t actually transmit the values as POST data via standard input in your successful case. You could simply swap POST(...) for GET(...) in that case and it should still work.

    In your unsuccessful case you use the POST HTTP method and the POST data way of transmitting the values.

    My verbiage here may be wrong in cases, but the fundamentals should still be OK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.