Exception calling "ExecuteQuery" with "0" argument(s): "The object specified does not belong to a list

Jones, Darren 1 Reputation point
2022-05-17T15:40:03.457+00:00

Hi,
I am trying to create some document set in SP online but getting the following error

Exception calling "ExecuteQuery" with "0" argument(s): "The object specified does not belong to a list."
At C:\DMS\DMSDocSetImport.ps1:31 char:2

  • $spoCtx.ExecuteQuery()

The script I am using:

202901-image.png

Any help appreciated.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,565 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,884 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 30,916 Reputation points Microsoft Vendor
    2022-05-18T02:05:20.55+00:00

    Hi @Jones, Darren ,
    The object specified does not belong to a list means that SharePoint attempt to get an Item(Specified by strUrl) that does not belong to the SPWeb.

    If you did not set some url correctly, this error may occur. Please check this link for more information.
    https://stackoverflow.com/questions/39413728/the-object-specified-does-not-belong-to-a-list-error-using-csom

    In your case, I guess the $CurrentDocSet or $spoDocumentSet didn't get the correct value. You can try to check the value of them or provide us with text documentation of the code so that we can test about the issue.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.