Click here to Skip to main content
11,704,509 members (55,290 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Perl
Hi,
I am try to get the list items from share point server site using perl script.i am write the script but give the error "401 Unauthorized". please help to solve this problem.

i am write script below

use LWP::UserAgent;
use LWP::Debug;
use Data::Dumper;
use SOAP::Lite on_action => sub { "$_[0]$_[1]"; };
import SOAP::Data 'name', 'value';
 our $sp_endpoint = 'http://sez2444/_vti_bin/lists.asmx';
 
 our $sp_username = 'spadmin';
 our $sp_password = 'Csc@1234';
 our $sp_domain = 'dev\';
print Dumper(dgfrdgfd);
$debug = 0;
 
if ($debug) {
LWP::Debug::level('+');
SOAP::Lite->import(+trace => 'all');
}
my @ua_args = (keep_alive => 1);
my @credentials = ($sp_domain, "", $sp_username, $sp_password);
my $schema_ua = LWP::UserAgent->new(@ua_args);
$schema_ua->credentials(@credentials);
$soap = SOAP::Lite->proxy($sp_endpoint, @ua_args, credentials => \@credentials);
$soap->schema->useragent($schema_ua);
$soap->uri("http://schemas.microsoft.com/sharepoint/soap/");
print "$credentials \n";
$lists = $soap->GetListCollection();
quit(1, $lists->faultstring()) if defined $lists->fault();
 
sub lists_getid
{
my $title = shift;
my @result = $lists->dataof('//GetListItemsResult/listitems/data/row');
foreach my $data (@result) {
my $attr = $data->attr;
return $attr->{ID} if ($attr->{Title} eq $title);
}
return undef;
}
 
sub lists_getitems
{
my $listid = shift;
my $in_listName = name('listName' => $listid);
my $in_viewName = name('viewName' => '');
my $in_rowLimit = name('rowLimit' => 99999);
my $call = $soap->GetListItems($in_listName, $in_viewName, $in_rowLimit);
quit(1, $call->faultstring()) if defined $call->fault();
return $call->dataof('//GetListItemsResult/listitems/data/row');
}
 
my $list_id = lists_getid('Disk Space');
print "List ID is: $list_id\n";
my @items = lists_getitems($list_id);
foreach my $data (@items) {
my $attr = $data->attr;
print Dumper($attr);
 
}
Posted 12-May-13 23:03pm
Edited 13-May-13 1:05am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 700
1 OriginalGriff 495
2 Andy Lanng 275
3 CPallini 242
4 Maciej Los 235
0 OriginalGriff 8,824
1 Sergey Alexandrovich Kryukov 8,247
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100