# GetUserDocumentNodes Method

## Overloads

| [GetUserDocumentNodes(Guid, Guid, String)](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetUserDocumentNodes.htm#PIX_Services_V12_Api3_IQMS3_GetUserDocumentNodes_System_Guid_System_Guid_System_String_) |  | Gets user document nodes for the specified relative path and the specified user document folder and QlikView Server ID. |
| --- | --- | --- |

[](https://help.qlik.com/en-US/qlikview-developer/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetUserDocumentNodes.htm) [](https://help.qlik.com/en-US/qlikview-developer/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetUserDocumentNodes.htm)

## GetUserDocumentNodes(Guid, Guid, String)

Gets user document nodes for the specified relative path and the specified user document folder and QlikView Server ID.

### Declaration

```

          List<DocumentNode> GetUserDocumentNodes(Guid qvsID, Guid folderID, string relativePath)
    
  
```

### Parameters

| Type | Name | Description |
| --- | --- | --- |
| System.Guid | qvsID | The QlikView Server ID for which to retrieve user document nodes. |
| System.Guid | folderID | The user document folder ID for which to retrieve user document nodes. |
| System.String | relativePath | The relative path for which to retrieve user document nodes. |

### Returns

| Type | Description |
| --- | --- |
| System.Collections.Generic.List&lt;[DocumentNode](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.DocumentNode.htm)&gt; | User document nodes for the specified relative path and the specified user document folder and QlikView Server ID. |

### Remarks

This method is typically used to retrieve the user documents as a tree structure. Each returned [DocumentNode](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.DocumentNode.htm) contains a [RelativePath](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.DocumentNode.RelativePath.htm#PIX_QMSAPI_DataObjects_DocumentNode_RelativePath) property which describes where in the tree structure the node belongs. It also contains a [IsSubFolder](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.DocumentNode.IsSubFolder.htm#PIX_QMSAPI_DataObjects_DocumentNode_IsSubFolder) property that indicates whether the node represents a sub folder or a document.

To retrieve the first level of nodes under the user document folder specified by `folderID`, set the `relativePath` parameter to an empty string. For deeper levels of nodes, set the `relativePath` parameter to a path combined of the relative path and the name of the parent node at the previous level.

##### security

Requires membership of local group *QlikView Management API* and the role *Document Folder Administrator*.

### Examples

The following code example uses the QMS API to retrieve a registered QlikView Server, all its user document folders and nodes. The [GetUserDocumentNodes(Guid, Guid, String)](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetUserDocumentNodes.htm#PIX_Services_V12_Api3_IQMS3_GetUserDocumentNodes_System_Guid_System_Guid_System_String_) method is called recursively to print sub folders and user documents as a tree structure. If anything goes wrong, it prints an error message.

The service key injection is assumed to be handled behind the scenes.

```
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using QMSAPI;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // create a QMS API client
            IQMS apiClient = new QMSClient();

            //retrieve a time limited service key
            ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();

            // get a list of QVS services
            List<ServiceInfo> qvsServices = apiClient.GetServices(ServiceTypes.QlikViewServer);
            if (qvsServices.Count > 0)
            {
                // retrieve all user document folders for the first QVS in the list
                Console.WriteLine("The " + qvsServices[0].Name
                    + " contains has following user document file structure:" + Environment.NewLine);
                List<DocumentFolder> userDocumentsFolders = apiClient.GetUserDocumentFolders(qvsServices[0].ID,
                    DocumentFolderScope.General | DocumentFolderScope.Services);
                // loop through all user document folders
                foreach (DocumentFolder userDocumentFolder in userDocumentsFolders.OrderBy(x => x.General.Path))
                {
                    // print the names of all user document folders,
                    // prefix with [R] for root folder and [M] for mounts
                    string folderPrefix = (string.IsNullOrEmpty(userDocumentFolder.General.Path) ? "[R]" : "[M]");
                    string folderName = (string.IsNullOrEmpty(userDocumentFolder.General.Path)
                        ? qvsServices[0].Name : userDocumentFolder.General.Path);
                    Console.WriteLine(folderPrefix + " " + folderName);
                    // print all sub nodes of the current user document folder
                    PrintUserDocumentNodes(apiClient, userDocumentFolder, string.Empty, 1);
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An exception occurred: " + ex.Message);
        }
        // wait for user to press any key
        Console.ReadKey();
    }

    static void PrintUserDocumentNodes(IQMS apiClient, DocumentFolder userDocumentFolder,
        string relativePath, int indentationDepth)
    {
        // retrieve all user document nodes of the given folder and under the specified relative path
        List<DocumentNode> userDocumentNodes = apiClient.GetUserDocumentNodes(userDocumentFolder.Services.QVSID,
            userDocumentFolder.ID, relativePath);
        // loop through all current user document nodes
        foreach (DocumentNode userDocumentNode in userDocumentNodes
            .OrderByDescending(x => x.IsSubFolder).ThenBy(x => x.Name))
        {
            // print the names of all user document nodes, indent and
            // prefix with [F] for folders and [D] for documents
            string indentation = new string(' ', indentationDepth * 3);
            string nodePrefix = (userDocumentNode.IsSubFolder ? "[F]" : "[D]");
            Console.WriteLine(indentation + nodePrefix + " " + userDocumentNode.Name);
            // print all sub nodes of the current user document node if it represents a folder
            if (userDocumentNode.IsSubFolder)
            {
                PrintUserDocumentNodes(apiClient, userDocumentFolder,
                    Path.Combine(relativePath, userDocumentNode.Name), indentationDepth + 1);
            }
        }
    }
}
```

### Exceptions

| Type | Condition |
| --- | --- |
| System.Exception | Thrown if the caller does not have access to the user document folder with the specified ID. |

### See Also

[DocumentNode](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.QMSAPI.DataObjects.DocumentNode.htm)

[GetUserDocuments(Guid)](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetUserDocuments.htm#PIX_Services_V12_Api3_IQMS3_GetUserDocuments_System_Guid_)

[GetUserDocumentFolders(Guid, DocumentFolderScope)](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetUserDocumentFolders.htm#PIX_Services_V12_Api3_IQMS3_GetUserDocumentFolders_System_Guid_PIX_QMSAPI_DataObjects_DocumentFolderScope_)

[GetSourceDocumentNodes(Guid, Guid, String)](https://help.qlik.com/en-US/qlikview-developer/September2026/Subsystems/QMSAPIref/Content/PIX.Services.V12.Api3.IQMS3.GetSourceDocumentNodes.htm#PIX_Services_V12_Api3_IQMS3_GetSourceDocumentNodes_System_Guid_System_Guid_System_String_)