Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
My question is if there is any help or guidance on how to use the QVS API besides the help file (which is not very helpful...).
It doesn't seem that there is much examples out there on how to use the QVS API. Please can anyone shed some light!
I need to use the API to get detailed license information, ie to whom is licenses assigned and usage, as well as reload scheduled information.
Any help would be appreciated!!!!
my bad .. your right
Stephan,
I`ve tried that out, but GetDocumentMetaData requires a DocumentNode, and i cant figure out how to get that from a Document Path.
I found a method GetUserDocuments, but i dont want to iterate every document to find the according one, do you have any other ideas?
Also, then how would i Add an authorization Entry to the Document Meta Data?
Thanks!
Pablo
check my example Pablo
Amien; your example does not show how to select one document. Also it handles user CALs, and not Document Authorization, that Pablo is asking for. 😃
Pablo; it depends on how your folder structure is on the server, I would say. If you have only one folder (root) you could just use something like this;
List<DocumentFolder> DocFolders = BackendClient.GetUserDocumentFolders(QvsGuid, DocumentFolderScope.All);
DocumentFolder Folder = DocFolders[0];
If you need to "pick" one item based on the objects in the List<>, you can do like this;
List<DocumentFolder> DocFolders = BackendClient.GetUserDocumentFolders(QvsGuid, DocumentFolderScope.All);
DocumentFolder Folder = DocFolders.Find(xxx => xxx.General.Path=="");
I hope that explains it somewhat.
Hi Stephan,
I get what you say, and that will help, but i still cant understand how to get the DocumentNode, that is what i will need in order to be able to SetMetaData (it requires the document node as a parameter).
With that final help, i think everything else i can work it out.
Thanks!
Pablo
Use the GetUserDocumentNodes function. 🙂
Here's my code. Maybe it'll help:
// Get an instance of the API
QMSBackendClient apiClient = new QMSBackendClient();
// Get a time limited service key
ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();
// Get an instance of the services on the Qlikview server
List<ServiceInfo> qvsServices = apiClient.GetServices(ServiceTypes.QlikViewServer);
// Get the document node of the 1 document you want it for
DocumentNode theDoc = apiClient.GetUserDocuments(qvsServices[0].ID).Single(x => x.Name == "The name of the doc you want");
// Get the document's metadata using the node
DocumentMetaData theDocMetaData = apiClient.GetDocumentMetaData(theDoc, DocumentMetaDataScope.All);
// Do what you need to with the document meta data
Here's an example of how to extract meta data for a document (Films) in the root folder, add an access post for a user, and save it back:
//*** Get user document folders
List<DocumentFolder> DocFolders = BackendClient.GetUserDocumentFolders(QvsGuid, DocumentFolderScope.All);
//*** Get root folder (either way)
//DocumentFolder Folder = DocFolders.Find(it => it.General.Path=="");
DocumentFolder Folder = DocFolders[0];
//*** Get document nodes with Folder ID
List<DocumentNode> Documents = BackendClient.GetUserDocumentNodes(Folder.ID, "");
//*** Get document meta data for specific document, only authorization scope
DocumentMetaData DocMetaData = BackendClient.GetDocumentMetaData(Documents.Find(it => it.Name == "Films.qvw"), DocumentMetaDataScope.Authorization);
//*** Add new access - make sure to populate the week list (cannot be null)
DocMetaData.Authorization.Access.Add(new DocumentAccessEntry { UserName = "domain\user1", DayOfWeekConstraints = new List<DayOfWeek>() });
//*** Save
BackendClient.SaveDocumentMetaData(DocMetaData);
Stephan and herman, Thanks a lot for both your help!
I will go one with your codes to develope everything i need.
Thanks a lot!
Pablo
Stephan,
Are you sure the method Add exist withing the Access methof of authorization?
DocMetaData.Authorization.Access.Add(new DocumentAccessEntry { UserName = "domain\user1"
I get an error message saying that System.Array does not contains a definition for Add.
thanks and sorry to continue bothering with this!
PAblo