in reply to SharePoint copy files with perl
I haven't tried exactly the thing you need to do, but I've had the "pleasure" of interacting with SP a couple of times.
I usually went with Soap::Lite as the module of choice, and was forced to use Authen::NTLM due to the proxy setup at work. Here is something that worked, printing first 10 records of a SP list, formatted as CSV. I must admit that much of this was borrowed from http://lifo101.wordpress.com/2012/05/08/sharepoint-and-ntlmv2-with-soaplite/.
#!/usr/bin/perl use v5.14; use Authen::NTLM; use SOAP::Lite; my %cfg = ( host => 'sp.hostname.net:80', # must include port endpoint => 'http://sp.hostname.net/tasks/_vti_bin/lists.asmx', user => '\\user', # must have leading backslashes pass => 'Pa$$w0rd', ); # enable NTLMv2 in Authen::NTLM ntlmv2(1); # syntax shortening of SOAP::Data methods sub name { my ($name, $value) = @_; my $d = SOAP::Data->name($name); return $d->attr($value) if (ref $value eq 'HASH'); return $d->value($value) if (defined $value); return $d; #otherwise } sub value { SOAP::Data->value(@_) } my $soap = SOAP::Lite ->proxy($cfg{endpoint}, keep_alive => 1, credentials => [$cfg{host}, '', $cfg{user}, $cfg{pass}]) ->default_ns('http://schemas.microsoft.com/sharepoint/soap/') ->on_action(sub { $_[0] . $_[1] }) # change default SOAPAction hea +der ->readable(1); # fetch the list my $list_name = '{B0101010-2323-3434-4545-565656565656}'; # Team tasks my $som = $soap->GetListItems( name(listName => $list_name), name(query => \value( name(Query => \value( name(OrderBy => \value( name('FieldRef' => {Name => 'Created', Ascending => 'F +alse'}), )), )), )), name(rowLimit => 10) ); die $som->faultstring() if defined $som->fault(); my @results = $som->dataof('//GetListItemsResult/listitems/data/row'); say "ID;Deadline;Owner;Task"; foreach my $data (@results) { my $item = $data->attr; say join(';', @$item{qw( ows_ID ows_Deadline ows_Owner ows_Task )} +); }
Still, If I had to do something like this now, I would probably look at SOAP::XML::Client, as it seems to have a nicer interface to it.
The worst part of the task is figuring out the xml query. I had it easy - I just went to my SP admins, armed with a bag cookies, and told them what I want to do. They figured out the xml query using SOAPUI, gave it to me, and ate my cookies. If this approach is available to you (and you have the cookies), it will make your task much easier.
regards,
Luke Jefferson
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SharePoint copy files with perl
by Anonymous Monk on Aug 11, 2016 at 01:29 UTC |