jamesgerard1964 has asked for the wisdom of the Perl Monks concerning the following question:

I need to push and pull files into a internal corporate sharepoint. I've never worked with a sharepoint before so forgive the questions. I downloaded the cpan module SharePoint::SOAPHandler. So, here is the sharepoint url:


https://operations.web.myworksite.com/sites/CAPCOET3/jim/SitePages/Home.aspx

So, the entries would include:
my $sharepointobj = SharePoint::SOAPHandler ->new;
$sharepointobj ->sp_creds_domain(’operations.web.myworksite.com:443′);
$sharepointobj ->sp_creds_user(’DOMAIN_NAME_CAPS\username’);
$sharepointobj ->sp_creds_password(’some_password’);

print “$_\n” for @{$sharepointobj ->fdls(”, ‘Shared_Documents’)};

Can anyone help filling out these fields based on the url above. Or if the SharePoint::SOAPHandler module is not the way to go maybe advice on the soap call. After googling I found that you can access the sharepoint like a windows share. I have samba working with linux to access windows shares, but haven't been able to do it here. Anyone know if that would be correct. Thanks.

Replies are listed 'Best First'.
Re: SharePoint copy files with perl
by runrig (Abbot) on Oct 02, 2014 at 21:49 UTC
Re: SharePoint copy files with perl
by blindluke (Hermit) on Oct 03, 2014 at 08:07 UTC

    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

      It worked great for me! Many thanks blindluke! Has anyone been able to do the same thing with SP2013 / Office 365?
Re: SharePoint copy files with perl
by dasgar (Priest) on Oct 03, 2014 at 21:37 UTC
Re: SharePoint copy files with perl (OT)
by dasgar (Priest) on Oct 03, 2014 at 21:54 UTC

    I can't help but think of the following text from http://shareperl.blogspot.com/2010/01/sharepoint-perl-connection.html whenever I see someone asking about how to use Perl to do something with SharePoint.

    Why on earth would these two disparate camps ever meet? Perl is 15 million years old, right, and SharePoint is the bane to system administrators everywhere. The small “SharePerl” audience includes me, and two or three really old techs that still use land line phones.

    Not really relevant to the OP, but thought I'd this in case others find this humorous too.

      I tried using the HTTP::DAV module and it appears to be setup correctly but I keep getting this error.

      Unauthorized. Negotiate

      I know that the credentials are correct as I am able to connect via a windows share.
      Does anyone know if there is some kind of issue with HTTP::DAV or NTLM authentication on Linux?

      I get the same unauthorized error if I use the SharePoint::SOAPHandler as well.
Re: SharePoint copy files with perl
by Anonymous Monk on Oct 03, 2014 at 19:51 UTC

    Our IT department at $work did some sort of black magic to make a network drive be a sharepoint interface so our test operators could update spreadsheets as if they were normal files.

    Perhaps just ask your infrastructure team to set up the share for you?