Questions tagged [csom]

The client-side object model (CSOM) provides access to a subset of the SharePoint Foundation server object model, including core objects such as site collections, sites, lists, and list items and allows you to program against these from client side applications.

Filter by
Sorted by
Tagged with
1
vote
2answers
2k views

Fix 401 Unauthorized Exception uploading file to SharePoint 2010

I have a WCF service hosted in IIS on Domain 1. This service is accepting a request to upload a file, and then uploading the file to a SharePoint 2010 Server on Domain 2, using the client object model....
1
vote
0answers
15 views

Why does this code works? Calling executeQuery without Load [CSOM]

First question: Why we don't need ctx.Load(web) before defining the List? I see that we use web object in defining the List Second question: Why are we not calling ctx.Load() before ExecuteQuery ...
2
votes
1answer
891 views

Get Principal By Id - Getting User or Group by ID

How to get a CSOM Principal from a user or group ID? For example to assign permissions stored in a "People" field (which can also contain groups). At the moment I have this super kludge using ...
1
vote
1answer
989 views

How to get the correspond listItem from the last major version of a file via CSOM

I am trying to get the last major version of a file in a sharepoint-list by using CSOM with the following Code: var web = clientContext.Web; var list = web.Lists.GetByTitle("MyList"); ...
0
votes
0answers
15 views

CSOM - .Net Core 3.1 - Getting access denied from the last context.ExecuteQuery(); when trying to create a sub web

Everything else works perfectly. Why am I getting an access denied when trying to execute this code ? string password = "password"; var securePassword = new System....
0
votes
0answers
15 views

Copy file and return meta data

i want to ask how to make return meta data especially GUID after copy or move data via csom? im using MoveCopyUtil.MoveFile(this.clientcontext,srcUrl,DstUrl,true,options); i have source url as ...
0
votes
0answers
11 views

Check if content editor or script editor web part is present in the list forms (New/Display/Edit form) using PowerShell (CSOM/PnP)

I am trying to check if the content editor or script editor web part is present on the list forms (NewForm, EditForm, DisplayForm) in SharePoint 2013. I can get the web part type from web part page ...
0
votes
0answers
23 views

You cannot load dependent objects for more than 1000 resources. Use a filter to restrict your query

I have on-premise SharePoint 2019 and MS Sql Server 2019. I use CSOM to set actual work for resources. public TimePhase getResourceTimePhaseAssignments(EnterpriseResource resource, DateTime startDate, ...
0
votes
0answers
15 views

Trigger an update on documents

We would like to trigger an update documents so they will be included in labeling in the compliance center. Is there a minimum call you can make to trigger an update on a document without changing ...
0
votes
0answers
14 views

CSOM-Sharepoint online console app c# 'ServerVersion' threw an exception of type 'Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException'

I am developing a simple code to retrieve item from Sharepoint online List. But on debug, I found an exception is thrown saying ServerVersion 'ServerVersion' threw an exception of type 'Microsoft....
2
votes
1answer
987 views

CSOM - How to rename a Document library

Is there a way in CSOM wherein I can rename document library using CSOM like we do in SPD(renaming the root folder)? I tried several ways e.g updateTitle,FileLeafRef. Also tried to rename a folder ...
1
vote
1answer
2k views

CSOM Powershell create subsite in subsite

Trying to create multiple things in PowerShell with CSOM for SharePoint Online: Create a project (subsite) in the site collection (root) Create a level (subsite) underneath the project subsite (so ...
1
vote
1answer
2k views

Lookup field value is not getting set when using Client object model

I have a document library (contact). Have created a custom list (workstatus). Have added column to contact library which is lookup of workstatus. Below is my code using which i am setting the lookup ...
0
votes
2answers
2k views

GetItems (CamlQuery) does not return all columns in the SharePoint list/ document library with REST API POST Request

Required to get all column data with CAML query with GetItems REST API query since with the requirement of getting managed metadata term values. But its not returning all columns and values. Query as ...
0
votes
0answers
25 views

ServerRedirectedURL has no value

Do you have any idea on what maybe the reason why I am getting empty string when using GetWOPIFrameUrl, also having null values on ServerRedirectedURL, ServerRedirectedEmbedURL, and ...
1
vote
1answer
2k views

Migrate documents to another site collection with versions using CSOM

I have two site collection on SharePoint online. I want to create web job to move all files to another site collection along with version. I have created one console application and written code in ...
1
vote
1answer
1k views

Sharepoint Online - Recover column from lists of project sites

I have a site collection with a lot of subsites attached to projects (each subsite is a site created by a project). Those subsites has a list with its fields. I executed a PowerShell script that ...
0
votes
2answers
2k views

SharePoint Error Invalid look-up value. A look-up field contains invalid data. Please check the value and try again

While trying to update a value in pages library, I am getting below error: Invalid look-up value. A look-up field contains invalid data. Please check the value and try again. This is happening for ...
0
votes
0answers
18 views

Executing a CAML query will return this error: “Specified argument was out of the range of valid values. Parameter name: index”

I have the following code inside our console application, to loop through a list of number and query the SharePoint list which is inside a modern communication site: foreach (var r in allrequests....
0
votes
1answer
3k views

Get person or group field from list then query user profile

I am currently working on SharePoint 2013 on premise and I am trying to use JavaScript to get the latest 3 "new starters" from a SharePoint list then return information about them such as the ...
0
votes
0answers
15 views

Microsoft.IdentityModel.SecurityTokenService.RequestFailedException: Token request failed

I have a .net console application which have this CSOM code:- using (ClientContext context = new PnP.Framework.AuthenticationManager().GetACSAppOnlyContext(RisksiteUrl, clientId, clientSecret, ...
1
vote
2answers
258 views

Problem with declaring ClientContext Object globally

I am working with SharePoint 2010 with Client Object Model(C#). I am having multiple function which does different operation with Lists and Library. In every method I have define a new object of ...
3
votes
1answer
3k views

CSOM The request uses too many resources error while provisioning web

I am provisioning web on SharePoint online using following CSOM code(provided hosted app), but intermediately we are getting "The request uses too many resources" error. using (ClientContext ...
3
votes
1answer
3k views

Access Old Version File objects with CSOM

I created a WCF service that uses Client-side Object Model (CSOM) to query file information from a SP Document Library. I need to create a List<File> with all the files associated with all the ...
1
vote
1answer
3k views

How to connect office 365 site having MFA using c#

I need to connect Office 365 site using console application(c#). but the problem is office 365 tenant having MFA(Multi Factor Authentication) authentication. How can i connect to specific site ...
0
votes
1answer
14 views

How to CheckOut, Update and CheckIn a new version of an existing Sharepoint Document in C#

I'm using C# CSOM to add documents to a Sharepoint library. I'm using the code below which works. How do I modify this code so that if the Document already exists in Sharepoint it will CheckOut the ...
0
votes
1answer
17 views

Get all content and child content inside a folder using sharepoint PNP framework

I can get all contents inside a SharePoint list like this: List list = oWebsite.Lists.GetByTitle("Documents"); ListItemCollection Items = list.GetItems(CamlQuery.CreateAllItemsQuery()); ...
0
votes
1answer
21 views

Bind a lookup field to a dropdown in Provider Hosted App SharePoint Online using CSOM/C#

I am trying to bind a lookup column named team to an asp.net dropdown and the dropdown renders blank HTML <asp:DropDownList ID="team" runat="server" AutoPostBack="true"...
1
vote
1answer
7k views

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

I am getting below error on the second request. Strange thing is its not occurring on first request. The collection has not been initialized. It has not been requested or the request has not been ...
0
votes
0answers
11 views

CSOM - ApplyProvisioningTemplate - Access denied. You do not have permission to perform this action or access this resource

I was using ApplyProvisioningTemplate function with PnP.Framework as below code for applying template . it used to work without an issue. but i randomly get the below error with following message . ...
0
votes
1answer
2k views

How to get document extension from a document library in SharePoint 2013 using Client Object Model?

I tried this code to get value : docEnumerator = collVideoLibrary.getEnumerator(); //Looping through the collection while (docEnumerator.moveNext()) { docItem = docEnumerator.get_current(); ...
0
votes
1answer
2k views

How to get All Users in User Profile Services Sharepoint 2013 Using CSOM

I need some function like bellow on CSOM. could you help me ? if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint....
0
votes
1answer
2k views

Update editor of published version without affecting version number - CSOM

I am trying to copy files from one site collection to another including their version history and preserve the metadata using CSOM. I am almost there using the below logic for each version of the file....
0
votes
1answer
2k views

How do I identify only the running workflow instances of a list item in Sharepoint Online CSOM

I am able to get all the workflows associated with a list item. But it looks like only one of the workflows can be running for the list item in this list. I want to be able to figure out which is the ...
5
votes
1answer
2k views

CSOM site provisioning error: The request uses too many resources

I continue to get an error (sometimes) when provisioning a web using CSOM. According to this MSDN article, this error is returned when the CSOM request exceeds 2MB. I watched the call in Fiddler and ...
0
votes
1answer
20 views

can any one provide complete script to compare csv file and SharePoint list column(People) and extract records not exist in SharePoint list

I have one excel file and a SharePoint list(Employee master). I want to extract the user in csv file who is not in the SharePoint list(Employee Master). If the employee not exists in SharePoint list ...
0
votes
1answer
115 views

Adding Folders using CSOM is raising this error “System.ArgumentException: 'The 'parameters.LeafName' argument is invalid.'”

I have the following CSOM inside my remote event receiver for SharePoint online site:- ListItemCreationInformation listItemCreationInformation = new ListItemCreationInformation(); ...
0
votes
1answer
23 views

How to find all subfolders inside a SharePoint Folder using PNP Framework

I want to find all the subfolders of a SharePoint folder using PNP framework. My current code is like this using (var cxt = new AuthenticationManager().GetACSAppOnlyContext(siteUrl, ...
0
votes
1answer
25 views

How i can secure ClientSecret for my app which i am using inside SharePoint asp.net console application

I have the following SharePoint asp.net console application, which runs each hour using windows tasks scheduler :- string clientId = "e***"; string clientSecret = "****"; string ...
0
votes
1answer
2k views

Sharepoint: inline image in email

I am unable to add inline images in an email. The mail just show a square having a red cross inside it. Is there a way to add inline images to email which needs to be sent from SharePoint. Updated: ...
1
vote
1answer
1k views

SharePoint Online - PowerShell - CSOM ExecuteQuery Exception is Root Element is Missing

I am used to working with SharePoint on-premises environments, but I am now trying to come up to speed with SharePoint Online. I can connect to my tenant using Connect-SPOService and use the ...
1
vote
1answer
56 views

Azure Function - SharePoint CSOM call with currently signed in user

I have a azure function and making a CSOM call to SharePoint online. The authentication was done with App ClientId & ClientSecret. Everything working fine. I am capturing a DocSet version via CSOM ...
0
votes
1answer
1k views

HTTP 403 Forbidden error for getchanges REST API call

I'm new to sharepoint and stuck with the below issue: Objective: To query for changes (updated or deleted list items) from Sharepoint online sites using REST API from a C# Console application. I ...
3
votes
1answer
1k views

Powershell CSOM folder.Files.Add(FileCreationInformation) Working earlier, Fails now?

Using Powershell and CSOM, on Sharepoint Online, I have successfully upoaded 300K pdf files w/metadata into folders in document libraries. Today, though, the same code is failing to Add files... ...
1
vote
0answers
39 views

Working with large amounts of folders

I'm in SharePoint Online, where I have to copy data from one list to another. My code already works on low amount of folders, but I have problems with large amount of folders. Example: LibraryA: ...
0
votes
0answers
13 views

Is there GetFieldDefaults for class Microsoft.SharePoint.ClientDocumentManagement.MetadataDefaults

I am trying to retrieve the value after first setting a default for a field at a location using the method SetFieldDefault(SPFolder, String, String). The reason for this is we are finding that some of ...
0
votes
2answers
1k views

SharePoint CSOM list group by and filter

I have a list with columns "fruit" and "ripeness". Using csom, how can I return "Banana" where Yellow count >= 3? ClientContext ctx = new ClientContext("https://sharepoint.blah.com"); List list = ctx....
5
votes
1answer
3k views

How to upload an attachment to a list item using Microsoft.SharePoint.Client?

I am trying to create a new list item with an attachment. Below is my code: using (var clientContext = new ClientContext(_sharepointSiteURL)) { clientContext.Credentials = _credentials; var ...
8
votes
3answers
3k views

CSOM Search API does not return all the results

I am having a problem with the code below. It is not returning all the rows/items which are found in different lists. The total number of items is 28, but the code below is returning 19. I have set ...

1
2 3 4 5
38