Questions tagged [c-sharp]
C# is one of the programming languages designed by Microsoft for the Common Language Infrastructure.
59
questions
0
votes
0
answers
150
views
C#: How to access MFA enabled SharePoint 365 Excel file via unattended application
I am new to programming SharePoint access in C#. We have a SharePoint 365 site with MFA enabled. I want to read an Excel file from the site and process it in my C# program. I am using .NET Framework 4....
0
votes
1
answer
133
views
Querying large number of search results fails occasionally with Search encountered a problem or timeout
We have some old timer jobs that have been developed some years ago, but we recently rewritten in an attempt to enhance the performance and prevent some issues like SharePoint Search encountered a ...
0
votes
1
answer
1k
views
How to filter query with multiple condition in URL - OData
I want to filter the data with Type 'Com and State 'Disconnected'. With below code i am getting the exception. How do I fix this?
Please help!
$filter=(contains(Type,'Com') and contains(State,'...
2
votes
0
answers
1k
views
SharePoint Server 2019 on-premise REST API Authentication
I need to read list data from SharePoint 2019 on-premise server, from an external server. I have tried calling the REST API but I am having trouble authenticating.
Things I have tried:
Calling REST ...
0
votes
1
answer
1k
views
How to update the value of a choice/multichoice column in Sharepoint online through coding
Is there a way through using a piece of code to update all the specific values of a column of SharePoint online to something else?
I am looking for an equivalent of the below SQL code for Sharepoint ...
1
vote
1
answer
174
views
How to modify the same attribute of multiple lists with exact schemas in Sharepoint online through coding or ms flow
I have several lists with the same exact schemas in SharePoint Online. How can I do the following?
1- How to add/remove a column to/from all of them?
2- How to add/remove an option to a choice/...
0
votes
1
answer
933
views
How to download all of the files under a specific folder using CSOM from SharePoint Online?
I have a folder structure similar to this on our SharePoint Online site:
Documents/
Drawings/
For Review/
Released/
Archived/
Documentation/
For Review/
...
0
votes
1
answer
311
views
Is it possible to add different person-value items to SharePoint list using CSOM? C#
I don't think it is possible, but hoping I am wrong. I'm using a CSOM in a C# application to update a SharePoint list (SharePoint Foundation server). All of the items on the list are updated correctly,...
0
votes
1
answer
42
views
When to use camlQuery?
When interacting with Sharepoint 2013 or Sharepoint Online, is the use of camlQuery recommended? I've had to pick up some CSOM knowledge of late on the fly via C#. I am having some success with it, ...
1
vote
0
answers
1k
views
SharePoint PnP provisioning engine: applying provisioning template throws "Access denied" error
I am currently facing a strange behaviour with the SharePoint provisioning engine. I am targeting a SharePoint 2019 on-premise version. I am quite sure that this problem is related to authentication, ...
2
votes
0
answers
521
views
CSOM - Get ClientContext current/pending request query size (no file)
In C#, when executing ClientContext.ExecuteQuery(), if the query sent to SharePoint has a size above 2MB, it returns an error like this:
The request message is too big. The server does not allow ...
1
vote
0
answers
104
views
CAML query for child properties
I have a CSOM query like this one:
_context.Load(currentItems,
lis => lis.Include(
i => i.RoleAssignments.Include(
ra => ra.RoleDefinitionBindings,
...
1
vote
3
answers
2k
views
Creating a sharepoint online site with C# [closed]
Hi I've succeeded creating document libraries and folders but I'm having trouble creating a (communication) site in SharePoint online.
Thanks for the help!
1
vote
1
answer
559
views
How to get list data from sharepoint list with lookup field values in asp.net mvc
I want to get data from a list. It contains some lookup fields. My problem is how to get lookup value from the list. I meant I want to expand lookup field values.
Here is the code I'm doing.
var ...
4
votes
1
answer
554
views
Get Value from SharePoint list into a Checkbox in C#
I have a SharePoint list that contain column 'District' with some data in it. It contains 4 value, District 1, District 2, District 3 and District 4.
I want to grab that value 'District' in the ...
0
votes
0
answers
653
views
Azure Functions and SharePoint Online - Newtonsoft.Json issue when calling ClientContex's "CreateSiteAsync" function
I'd like my Azure Function to be triggered on Azure Queue events, and use the event data when communicating with SharePoint Online. The first SharePoint task would be to provision new sites based on ...
1
vote
1
answer
281
views
Sharepoint online/365 integration (Upload files) on React app hosted on Azure and WebApi C# .Net Core 2.2
I'm struggling since some weeks ago trying to interact/automate a way to upload files from a Web App created in React and upload files to a Sharepoint Online Site – in a specific folder. The WebApp is ...
1
vote
2
answers
530
views
CSOM: How to know if a Web has completed its creation?
I have a service that creates a Sharepoint Online site using CSOM.
context.Web.Webs.Add(webCreationInformation);
context.ExecuteQuery();
This site is created using a defined Template stored in the ...
1
vote
1
answer
850
views
Custom action not working in SharePoint 2019 on premise
I have a problem with a custom action in SharePoint 2019 on premise. The custom action adds a link in the menu item of the SharePoint menu bar. It's a mysite collection.
SharePoint 2013 (it works):
...
1
vote
2
answers
3k
views
Upload Multiple Documents to SharePoint Online using C#
I've been trying for a while to make this work, but I'm stuck. I've checked all the solutions around here and google, but can't seem to figure out why I keep getting an error.
string targetFolder = "/...
0
votes
1
answer
140
views
Getting data from another website using C# and displaying in a web part
I'm trying to read information sitting in another wesbsite using C# and displaying the result in sharepoint 2010 web part. I read about httprequest but I'm failing to implement it. Please anyone help ...
1
vote
0
answers
143
views
Modify the List View Web part's Miscellaneous ( Form Template Name ) value using C# in SharePoint 2016
Is there any way to change the List View Web part's Miscellaneous ( Form Template Name ) value using C# in SharePoint 2016
0
votes
1
answer
420
views
getting all AD groups and users of a site collection
Hello everybody I am quite new to the Sharepoint, I am trying to get all the AD groups who have permissions on a sitecollection.
I am able to get all the SPgroups and users using the code below in my ...
1
vote
1
answer
542
views
Use HttpWebRequest with SharePoint Online and ADAL
I have a C# desktop application which uses ADAL and the SharePoint Online CSOM to access SharePoint Online. The CSOM methods all work great, but sometimes I use a HttpWebRequest when I need to resolve ...
0
votes
0
answers
961
views
System.InvalidOperationException: 'This property cannot be set after writing has started.' for OpenBinaryDirect
I am getting "System.InvalidOperationException: 'This property cannot be set after writing has started.'" when calling OpenBinaryDirect().
Please check below code and suggest.
public static void ...
1
vote
1
answer
52
views
Sharepoint Online, Getting the Versions of a document only returns older versions of the document and not the current
I am developing a desktop app in c# using CSOM to run against an o365 SharePoint solution.
I managed to get the version, however in testing I have noticed that I am always getting the second newest ...
0
votes
1
answer
24
views
Content Search Webpart is not displaying after adding ddl.ClearSelection()
I'm having issue on asp:dropdownlist and search result display. One of the issues is "Cannot have multiple values on DropDownList", so, I looked it up and most of the suggestion were the use of ...
2
votes
2
answers
12k
views
How to upload a document in a SharePoint list using Graph API
We have been trying to add a document to a list item using Graph API but are being thrown a 400 error :( We have the access token and can query the list in question without any problem. Below is the ...
1
vote
0
answers
92
views
SharePoint 2010 Workflow: SPContext.Current.Web.URL returning Object reference not set error
I have a workflow that I have created for an SP 2010 site that does a basic approval process. In the workflow I have a couple of methods that create an email that is sent out to first the approving ...
0
votes
1
answer
413
views
How to get default Pages folder programmatically in Sharepoint 2013
Using C# in Sharepoint 2013 I can reach Pages folder using web.Folders["Pages"] or web.GetFolder("Pages")
Some of our SPWebs are in Turkish language. Whole interface is in Turkish including all ...
0
votes
2
answers
33
views
Please advice on rewrite event receiver code on SP2010
Recently I need to take care an SP2010 farm which I am not familiar. There is an event receiver with part of code as below:
SPListItemCollection ListA = properties.Web.Lists["ListA"].Items;
List<...
0
votes
2
answers
761
views
Programmatically move site to another site collection
In SP 2013, on prem, we need to move a sub site from one site collection to another - with all its permissions and versions of documents.
I am thinking of writing this in a SharePoint timer job with ...
0
votes
1
answer
2k
views
I want to retrieve data from SharePoint list using c# and store them into SQL server DB tables. How can I do this?
using ( SPSite site = new SPSite ("http://somesite/sitename"))
{
SPWeb myWeb = site.OpenWeb();
SPList target = myWeb.Lists["YourListName"];
SPListItems items = list.Items;
myWeb....
1
vote
0
answers
1k
views
Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. \"File\r\n\"
I am trying to edit an existing page with this code. When I am setting a publishComment it is throwing this exception.
item["Title"] = pageTitle;
item["PublishingPageContent"] = pageContent;
item....
0
votes
1
answer
33
views
Hide Wiki Page template from Site Actions>More Options in sharepoint 2010 programmatically
I want to hide the option of creating wiki page which is accessed via "Site Actions>More Options>Page" under Page type for all the users. I tried to find the display name and scope for deactivating ...
1
vote
0
answers
109
views
How to Download files from a sub folder? COM
I am trying to make a method that will allow me to use the parameter for folderName to update the path of file location within SharePoint. However, I am having some issues with getting the proper URL ...
0
votes
2
answers
5k
views
How to Upload to SharePoint using a memory stream? Using CSOM
I am creating a method to UploadDocument_FromStream() method which has one parameter -- Stream file.
I am having trouble trying to keep my SharePoint connection open to allow me to upload my Stream ...
1
vote
3
answers
4k
views
Creating a sub-folder in a SharePoint with Client.dll in C#
I am trying to create a list of all the folders that exist within the root folder. From there I want to implement the creation of a folder if the folder does not already exist.
Is there a way to ...
1
vote
2
answers
1k
views
How to test if a SharePoint connect is successful with user credentials using Unit testing C#
I am working on a project where I am trying to test if a user has successfully logged in with valid credentials using the Microsoft.SharePoint.Client.dll.
Currently my code is checking the HTTP ...
1
vote
3
answers
3k
views
Add resource assignment work by day
For a few days I'm trying to write the assignment progress for a specific task for a specific date. For example: I'm able to set the overall progress of the task but not the actual work that resource ...
0
votes
1
answer
830
views
"Sign in as different user" code not working
I am trying to implement the functionality for "Sign in as different user" link button on my custom access denied page in sharepoint 2010 using the below code
string site = base.Web....
0
votes
1
answer
204
views
Facing Error while accessing SharePoint site list, The remote server returned an error: (401) Unauthorized
I am getting following error
"The remote server returned an error: (401) Unauthorized."
While I'm trying to read a website hosted in SharePoint.
I have tried following code to access my ...
-1
votes
1
answer
3k
views
Status Code:500 Internal Server Error, while calling a webmethod in SharePoint 2013
I am trying to call a webmethod written on application page but getting an error,
Status Code:500 Internal Server Error
JavaScript:
<script type="text/javascript">
$(document).ready(...
3
votes
1
answer
53
views
Format data from multiple lists in Visual Web Part formatted like Standard List
I'm trying to roll data from multiple lists into one web part using Visual Studio, preferably a Visual Web Part. I want it to look like a normal SharePoint list view, with options to sort, filter, and ...
0
votes
0
answers
538
views
Gridview Databinding method in sharepoint
I know I have done something wrong so I need some suggestion about writing the below code.
protected void Page_Load(object sender, EventArgs e)
{
SPWeb web = SPContext.Current.Web;...
0
votes
1
answer
69
views
Update link in GridView
I have written the below code for updating gridview, It's not working.
protected void Update_row(object sender, GridViewUpdateEventArgs e)
{
try
{
//TextBox ID = (...
1
vote
1
answer
102
views
Null Reference error in gridview code
While debugging I found that ItemID value is getting null. I am trying to get the list item's ID.
ItemId = GridView1.DataKeys[e.RowIndex].Value.ToString();
Can anyone please tell me what could ...
-1
votes
1
answer
295
views
sharepoint 2013 C# update people or group
I have a requirement to move few of the items from Calendar A to Calendar B. How do I copy the below column values from A to B using C#?
Attendees, Free/Busy, Resources, CheckDoubleBooking, Category
...
0
votes
1
answer
665
views
Creating Visual Web part for file upload
I am trying to create a visual web part to upload documetns using FileUpload control. Below is the working code for uploading a file.
protected void UploadButton_Click(object sender, EventArgs e)
...
0
votes
1
answer
3k
views
How to get document item ID of a Document Library given Item Path - using c#?
I can't figure out how to get the item ID of a document library from the crawled or managed properties. So I decided to get it using the item Path which return the document Url allowing to download it....