.NET King Logo Comments on: SharePoint Client Side Object Model tutorial - Part 1
Skip Navigation Links
0 Items in Video cart!

SharePoint Client Side Object Model tutorial - Part 1 (10/16/2016)
In this video series I started an easy to understand tutorial for SharePoint client side object model.
This specific video includes an overview of CSOM using C# and explains references and main .NET objects used to make a simple Windows application that connects to SharePoint 2013/2016.

By: Sears  
This is my first time pay a quick visit at here and i am really
pleassant to read everthing at one place.
URL: http://a8.net  
By: Air Jordan 3 Mens  
Hello there, I found your website by means of Google while searching for a similar topic, your site got here up, it appears to be like good. I've bookmarked it in my google bookmarks.
URL: http://www.nikeoutlet-storeonlineshopping.com/air-jordan-3-mens-c1_6.html  
By: Fitflop Slide Sandals  
There is evidently a lot to realize about this. I believe you made certain good points in features also.
URL: http://www.fitflopssaleclearanceuk.com/fitflop-slide-sandals-c3.html  
By: Dinesh Rakhyani  
Hello Alizera,

Your tutorials are awesome, I had no background on SharePoint Technology, but now refering your tutorials i have learnt a lot.

Question:
I am trying to automate where a script will run on daily basis using task scheduler where it will upload a file on sharepoint site. I am using the below script to upload.

"
#Specify tenant admin and site URL
$User = "XXXX"
$SiteURL = "https://sites-apps.abb.com/sites/BAU/Country Exchange/FR/Consumption Reports"
$Folder = "C:\Export"
$DocLibName = "DocLib"

#Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString

#Bind to site collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
$Context.Credentials = $Creds

#Retrieve list
$List = $Context.Web.Lists.GetByTitle($DocLibName)
$Context.Load($List)
$Context.ExecuteQuery()

#Upload file
Foreach ($File in (dir $Folder -File))
{
$FileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMode]::Open)
$FileCreationInfo = New-Object Microsoft.SharePoint.Client.FileCreationInformation
$FileCreationInfo.Overwrite = $true
$FileCreationInfo.ContentStream = $FileStream
$FileCreationInfo.URL = $File
$Upload = $List.RootFolder.Files.Add($FileCreationInfo)
$Context.Load($Upload)
$Context.ExecuteQuery()
}
"

However i am getting the below error message.

Exception calling "ExecuteQuery" with "0" argument(s): "Cannot contact web site 'https://sites-apps.abb.com/' or the web site does not support SharePoint
Online credentials. The response status code is 'Forbidden'. The response headers are 'X-SharePointHealthScore=0,
SPRequestGuid=01ca4f9e-1f56-f01f-3e9d-93bab622ad4c, request-id=01ca4f9e-1f56-f01f-3e9d-93bab622ad4c,
X-Forms_Based_Auth_Required=https://sites-apps.abb.com/_login/default.aspx?ReturnUrl=/_layouts/15/error.aspx,
X-Forms_Based_Auth_Return_Url=https://sites-apps.abb.com/_layouts/15/error.aspx, X-MSDAVEXT_Error=917656; Access denied. Before opening files in this
location, you must first browse to the web site and select the option to login automatically., MicrosoftSharePointTeamServices=15.0.0.4709,
X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=13, Content-Type=text/plain; charset=utf-8, Date=Sat, 03 Mar 2018
06:01:15 GMT, Server=Microsoft-IIS/8.5, X-Powered-By=ASP.NET'."
At line:20 char:1
+ $Context.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NotSupportedException

New-Object : Exception calling ".ctor" with "2" argument(s): "The process cannot access the file 'C:\Export\ACLList.txt' because it is being used by
another process."
At line:25 char:15
+ ... ileStream = New-Object IO.FileStream($File.FullName,[System.IO.FileMo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

Exception calling "ExecuteQuery" with "0" argument(s): "Cannot contact web site 'https://sites-apps.abb.com/' or the web site does not support SharePoint
Online credentials. The response status code is 'Forbidden'. The response headers are 'X-SharePointHealthScore=0,
SPRequestGuid=01ca4f9e-ff6d-f01f-17ff-e9f4db1b179a, request-id=01ca4f9e-ff6d-f01f-17ff-e9f4db1b179a,
X-Forms_Based_Auth_Required=https://sites-apps.abb.com/_login/default.aspx?ReturnUrl=/_layouts/15/error.aspx,
X-Forms_Based_Auth_Return_Url=https://sites-apps.abb.com/_layouts/15/error.aspx, X-MSDAVEXT_Error=917656; Access denied. Before opening files in this
location, you must first browse to the web site and select the option to login automatically., MicrosoftSharePointTeamServices=15.0.0.4709,
X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=13, Content-Type=text/plain; charset=utf-8, Date=Sat, 03 Mar 2018
06:01:16 GMT, Server=Microsoft-IIS/8.5, X-Powered-By=ASP.NET'."
At line:32 char:1
+ $Context.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NotSupportedException

Could you please help me resolving this issue.
URL:  
By: mu2zen  
This is a very good game, I hope to play with you
mu2zen https://www.glassdoor.com/member/account/settings_input.htm
URL: https://www.glassdoor.com/member/account/settings_input.htm  
Your name:
Email:
URL:
Comments:
 

 -