0

I have SharePoint document library titled "Data Source" which consists of reporting data source files. Below images shows list of rsds file with associated connection string on click of each rsds file.

I would like to get the connection string associated with the file using CSOM or REST. Using below approach I could only get file name not the connection string. Do we have any fields to retrieve connection string?

Environment: SharePoint 2016 On Premise.

class Program
{
    static void Main(string[] args)
    {

        using (ClientContext ctx = new ClientContext("https://idev9/apps01"))
        {
            Web web = ctx.Web;
            ctx.Load(web);
            Microsoft.SharePoint.Client.List docList = web.Lists.GetByTitle("Data Sources");
            ctx.Load(docList);
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = "<View Scope='RecursiveAll'></View>";
            ListItemCollection listCol = docList.GetItems(camlQuery);
            ctx.Load(listCol);
            ctx.ExecuteQuery();
            foreach (Microsoft.SharePoint.Client.ListItem item in listCol)
            {
                Console.WriteLine("FileDirRef: {0}", item["FileDirRef"]);
                Console.WriteLine("FileLeafRef: {0}", item["FileLeafRef"]);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}

enter image description here

enter image description here

  • The string is within the file itself; SharePoint is just giving us a friendly way to update the file via the UI. Have you downloaded the file and parsed it as an XML document? – Trevor Seward May 29 '18 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.