Hi all,

I want to Pass the credentials and the Post parameters in a request and need to 
get the response content.

I tried with the following approach. 

1) Credentials are getting passed correctly however am not getting the 
parameter passed. 

2) If am passing the credentials in the url it is working fine. I want to pass 
the credential in header

3) Getting 401 - AUTH_REQUIRED Message

Method I:

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common;
use Data::Dumper;
my $ua = new LWP::UserAgent;
$username = 'username';
$password = 'password';
$uri = 'https://url/goeshere';
$in = {'test1' => 'test'};
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST => $uri,Content => $in);
$req->authorization_basic($username, $password);
$req->header("Content-Type" => "application/x-www-form-urlencoded");
my $output=$ua->request($req)->content;
print Dumper $output;

Method II:

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common;
use Data::Dumper;
my $ua = new LWP::UserAgent;
$in = {'test1' => 'test'};
my $res = $ua->post('https://username:[EMAIL PROTECTED]/goeshere', $in);
print Dumper $res->content;

Method III:

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common;
use Data::Dumper;
my $ua = new LWP::UserAgent;
$url = "https://url/goeshere";;
$in = {'test1' => 'test'};
$ua->credentials($url, 'TESTREALM', 'username' => 'password');
my $res = $ua->post($url, $in);
print Dumper $res->content;


Please guide me, 

I want to Pass both credentials and parameters through headers.

Thanks,
Prabu



      Unlimited freedom, unlimited storage. Get it now, on 
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to