0

I am the admin of SP2016. I have created folders inside my site. When I access sharepoint via browser, I'm able to enumerate through all the flders/files. I'm trying to write a program via CSOM. Via code, I'm not able to access some of the folders, I get the following exception.

2019-04-10 12:24:07.548 36 ERROR User cannot be found. 2019-04-10 12:24:07.548 8 ERROR Get:: Exception thrown Message(User cannot be found.) StackTrace( at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse() at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb) at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery() at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery() at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()

Any idea why ?

EDIT: Adding code

            if (type == "folder")
        {
            Microsoft.SharePoint.Client.Folder folder = webClientContext.GetFolderByServerRelativeUrl(relativeUrl);
            clientContext.Load(folder);
            clientContext.Load(folder.Folders);
            clientContext.Load(folder.Files,
                files => files.Include(file => file.Name)));
            item = folder;
        }
        else if (type == "file")
        {
            Microsoft.SharePoint.Client.File file = webClientContext.GetFileByServerRelativeUrl(relativeUrl);
            clientContext.Load(file);
            item = file;
        }
    }

    try
    {
        clientContext.ExecuteQuery();
    }
    catch (Exception ex)
    {
    }
  • You need to share you CSOM code. Are you using document sets in this library by any chance? – Marek Sarad Apr 11 at 10:28
  • Thank you for the reply! I've updated the code. – harinimurugan Apr 15 at 11:26
  • What about second part of my question. Are you using document sets? – Marek Sarad Apr 15 at 12:31
  • Sorry, I had missed that. No, we are not using any Document sets. Thanks! – harinimurugan Apr 16 at 5:11

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.