On Nov 8, 2010, at 7:48 AM, Kevin Philp wrote:

> Should your response line be
> 
> my $response = $ua->request(PUT $url, @headers, Content => @form_data);

This is wrong. The PUT method does have any common content forms, such as a 
POST, so it simply expects a chunk of some data that will be put. Hence, 
"Content" must refer to a scalar value--it is specifically the content that you 
wish to "put" onto the server. If you are using a form to submit a file, you 
need to extract out the file data and send only it as content.

> -----Original Message-----
> From: Paul Miles <[email protected]>
> To: [email protected]
> Subject: problems using PUT
> Date: Mon, 8 Nov 2010 14:29:28 +0000
> 
> 
> #!/usr/bin/perl
> 
> use strict;
> use LWP::UserAgent;
> use HTTP::Cookies;
> use HTTP::Request::Common;
> use warnings;
> 
> our $COOKIE_JAR_DIR="/root/cookie_jar";
> our $COOKIE_FILE="$COOKIE_JAR_DIR/cookies.txt";
> 
> my $url = "https://my.rightscale.com/api/acct/xxxx/servers/yyyyy";;
> 
> my @headers = ('X-API-VERSION' => "1.0");
> my @form_data;
> push @form_data, 'server[parameters][DNSMADEEASY_DNSIDS]' =>
> 'text:1234';
> 
> my $ua = LWP::UserAgent->new;
> my $response = $ua->request(PUT $url, @headers, Content => \...@form_data);
> 
> if (!$response->is_success) {
>  print $response->decoded_content;  # or whatever
>  die $response->status_line;
> }
> 
> print $response->decoded_content; 
> 


Keary Suska
(719) 473-6431
(719) 440-9952 (cell)

Reply via email to