C# : Uploading a document to SharePoint 2010 using Web Service - c#

Im having some trouble. I have a document library that contains a custom column ("Category"), this is just a lookup from the "Category" List.
I am able to upload the document successfully, however i sould like to set that category list aswell.
I am uploading to the document library using the SharePoint web services located here : [sharepointurl]/_vti_bin/copy.asmx
Regards
Jean

Once you have uploaded the document you can use "UpdateListItems" in lists.asmx to update the column you want for the new item.

Related

Using MS Graph to Read Excel Contents Through Sharepoint

I'm attempting to use MS Graph to parse the contents of excel files and sync the data with other business-line applications. The issue I'm running into is actually getting at the data in excel.
I'm using a ClientCredentialProvider authenticating to an Azure AD App Registration which has FullControl and Read.All permissions in my tenant to create my GraphServiceClient, and can successfully query the Site via ID, and even see the document library I'm trying to access, but the Items comes up empty. See below
var result = _graphService.Client
.Sites["my-site-id"] // This works
.Drives["site-drive-id"] // This works to find the document library
//.Lists["list-id-corresponding-to-folder"] // This also works to find that folder
.Items // ****This is null****
.Request()
.GetAsync()
.Result;
I tried using the Lists property (as noted above) because as I understand it document libraries in SharePoint are really just lists, but again the Items enumeration yields no results.
I can't find documentation on Microsoft's site on this use case, and I notice using the MS Graph Explorer that the returned object doesn't have an "items" field (or many properties in the Microsoft.Graph.Site class), but I would think there is some way to get this field populated since it's implemented in the Microsoft.Graph namespace. Not sure if I'm missing some permissions step or what, but if I can access the site with FullControl I should be able to access all its contents...
I can't use Client.Me (personal drive) as a source location because 1) the application doesn't run under my permissions and 2) there is a need to read multiple files; the idea would be just provide the needed site/drive/item ID's and get the documents.
Is there some other way I should be going about this?
#broccoli_rob,
MS Graph has not exposed the functionality of enumerating all items in a drive. Instead, you can only list children or get item by id.
We suggest you use /drive/root:/{item-path} to get items in a folder. And you can vaild the endpoint in Graph explorer:
BR

How to prevent access to _VTI_BIN folder on SharePoint and we are using content search query Webpart?

We are Using content search query Webpart to preview site content on SharePoint and when we prevent access to _VTI_BIN for security reason we run the search crawler a new contents doesn't show up in the search query web part.
Prevent _vti_bin folder access is not supported in SharePoint, as SharePoint needs to make calls to this folder eg ListData.svc web service, you should contact with your security coworker to specify this point, here is a similiar question for your reference:
Restricting access to contents in “_vti_bin” for both authenticated as well as anonymous users

Get the UNC of a file that the end user selects

I am trying to create a Sharepoint webpart for a user to browse to, and select, a file from a share on our file server. Then I need to create a link to this file to display in a list of links that will go onto our Sharepoint intranet page. I have created a custom web part using asp.net/c# in order to do this but I am stuck on how to get the UNC path to the document. From my understanding it wont work with an asp.net fileupload control or a html input element. What other options would there be? I really don't want the user to have to type in the whole path to the document. This needs to be a re-usable solution so that my users can create new lists of links to documents when they so desire. Thanks for any advice.
I don't think the full file path is supported or allowed via modern web browsers via the file upload control. What you would end up having to do is create something server-side that use a service account to access the file share, and then the client (web page) could call the server-side code as it traverses the file share until the user selects a file.
Example:
server: on load, here are the contents of "\server\home"
client: show the contents of subfolder "\server\home\pictures"
server: connects to "\server\home\pictures" and returns contents
client: selects "\server\home\pictures\foo.jpg"
Check out System.IO.Directory http://msdn.microsoft.com/en-us/library/system.io.directory(v=vs.100).aspx for ways to get listing of directory contents server-side (GetFiles, GetDirectories, GetFileSystemEntries, etc) and then you can return those results to the client.

How to quickly find document using guid in SharePoint Foundation 2010?

We have multiple content databases and each content database have multiple site collection. Site collection is having document libraries. We are using them to store documents. We have guid (UniqueId) of content database, site collection, document library and uploaded document. Is there any way to quickly find the document using Server Object Model rather than using old approach (using objects SPSite, SPWeb, SPList, SPQuery) ? Can you please provide me any code or link through which I can resolve the above issue ?
I'm afraid you cannot query multiple sites with one single query using SharePoint server object model. What you can do instead is to use "SPSiteDataQuery" which queries ONE site collection and in multiple libraries. read about it here:
MSDN: SPSiteDataQuery
Another option which will not use Server Object Model is to query the SQL Server Database directly (which is not recommended: Five Reasons Not to Directly Query SharePoint Databases). In order to do that you have to query against "All Docs" table in the content database of your web applications, gather the results, and use SiteId, WebId, ListId and ItemId columns and then use Server Object Model to find your document.

reporting services and custom datasource

I'm new to reporting services and ask for the possibily of using custom object as datasource? i'm using asp.net, visual web developer 2008 express edition and c#, if yes can you give an example. thanks for help
You can't use POCO as a data source directly in reporting services. There are a few ways to do this.
The simplest it to save your data to a database and query the database.
You could serialize the object to XML and query that by either including the XML directly into your query in an <XmlData> element, or calling a web service to retrieve the XML.
Create an XML Data Source for a Web Service
In your report project, right click on the Shared Data Sources folder.
Select Add New Data Source.
Set the Name to use.
Set the Type to XML.
Set the connection string to http://MyWebServer/MyWebServiceEndpoint.asmx.
Go to the Credentials page.
Configure the authentication.
Click OK.
You'll need to examine the WSDL for the web service and see the following references to help you build the query:
Reporting Services: Using XML and Web Service Data Sources
XML Query Syntax for XML Report Data (SSRS)
Element Path Syntax for XML Report Data (SSRS)
Here's a list of supported data sources from msdn: Data Sources
You would simply add a shared data source to your project (example: MyDataSource.rds) and choose from the available types. There, you would simply supply the appropriate credentials. Each of your reports would use the data source.
EDIT
Here's a simple tutorial on adding a data source: Creating a Shared Data Source in Reporting Services

Categories

Resources