2 Replies Latest reply: Jan 26, 2015 11:55 AM by Xavier Simms RSS

    Issues with retrieving document node list and user access list from API

      When I run the code it successfully retrieves the list of documents from the QDS, but throws an exception when the "GetDocumentMetaData" method is called an exception is thrown.

       

      Document ID: b7731ba0-6c3f-4566-7499-5e12ee0c2294
      An exception occurred: System.Exception: Failed to load because item with ID 00000000-0000-00
      00-0000-000000000000 does not exist.

       

      I can see that the correct document ID is being retrieved by printing it to the screen before making the call to the "GetDocumentMetaData", however the exception states that the ID being used is "00000000-0000-00
      00-0000-000000000000". While the document ID is actually "b7731ba0-6c3f-4566-7499-5e12ee0c2294".

      I am using Version 1.0.11440 on the Server.

       

      Here is the code sample.

       

      List<ServiceInfo> qdsServices = apiClient.GetServices(ServiceTypes.QlikViewDistributionService);
                  DocumentMetaData docMeta = new DocumentMetaData();
                  if (qdsServices.Count > 0)
                  {
                      // retrieve all user documents for the first QDS in the list
                      IList<DocumentNode> userDocuments = apiClient.GetSourceDocuments(qdsServices[0].ID);
                    
                      // print the names of all user documents
                      Console.WriteLine("The " + qdsServices[0].Name + " contains the following user documents:" + Environment.NewLine);
                      foreach (DocumentNode userDocument in userDocuments)
                      {
                          Console.WriteLine(userDocument.Name);
                          Console.WriteLine("Document ID: " + userDocument.ID);
                          //Get the user Access list for each document
                          docMeta = apiClient.GetDocumentMetaData(userDocument, DocumentMetaDataScope.Authorization);

       

                          Console.WriteLine(userDocument.Name + " User Access List");
                          //Print the name of each user that has access to the current document
                          foreach (DocumentAccessEntry D in docMeta.Authorization.Access)
                          {
                              Console.WriteLine(D.UserName);
                          }
                        
                      }

        • Re: Issues with retrieving document node list and user access list from API
          Bas Knol

          Hi Xavier,

           

          The problem here is that you are trying to request document meta data for a source document instead of a user document.

           

          The code comment states that user documents will be retrieved, but the function GetSourceDocument is called

           

          // retrieve all user documents for the first QDS in the list
          IList<DocumentNode> userDocuments = apiClient.GetSourceDocuments(qdsServices[0].ID);
          
          
          
          

           

          The code below should work.

           

          List<ServiceInfo> qvsServices = apiClient.GetServices(ServiceTypes.QlikViewServer);
          DocumentMetaData docMeta = new DocumentMetaData();
          
          if (qvsServices.Count > 0)
          {
              // retrieve all user documents for the first QDS in the list
            IList<DocumentNode> userDocuments = apiClient.GetUserDocuments(qvsServices[0].ID);
                       
            // print the names of all user documents
            Console.WriteLine("The " + qvsServices[0].Name + " contains the following user documents:" + Environment.NewLine);
            foreach (DocumentNode userDocument in userDocuments)
            {
                Console.WriteLine(userDocument.Name);
                Console.WriteLine("Document ID: " + userDocument.ID);
          
                //Get the user Access list for each document
              docMeta = apiClient.GetDocumentMetaData(userDocument, DocumentMetaDataScope.Authorization);
          
              Console.WriteLine(userDocument.Name + " User Access List");
              //Print the name of each user that has access to the current document
              foreach (DocumentAccessEntry D in docMeta.Authorization.Access)
              {
                    Console.WriteLine(D.UserName);
              }
            }
          }
          
          
          
          

           

          Bas Knol

          The Implementation Group

          • Re: Issues with retrieving document node list and user access list from API

            Thank you!

             

            Worked like a charm once I made the change to GetUserDocuments.