56 Replies Latest reply: Oct 1, 2012 9:30 PM by Arnold Ayaoan RSS

QVS API Support

hermandup

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!!!!

  • QVS API Support
    Deepak Kurup

    hi

    Once you hae installed Qlikview server. QVsRefrence manul is stored in the installation folder.

    check out you C:\Programfiles\Qlikview\Document.

    It would be helpful in knowing the API of Server.

  • QVS API Support
    Sunil Jain

    qlikview server reference manula and QVS API both are different thing.

    QVS API helps in how to use packeges OR library but qlikview server reference manula not.

  • QVS API Support
    Deepak Kurup

    hi,

    If you can specify exactly what your are looking at then we might be able to help you out.

    If you want to see information like how to relaod using Server or Reload status etc you will find it in QVS Refrence manul page no 65 .

    It might give you fair bit of idea.

    • QVS API Support
      hermandup

      Thanks for the reply.

      I need to

      1. Get a list of all the schedules for reloads. We don't have the Publisher, so it's the reload schedules that can be set up in the Management Console.

      2. See the users who has Doc CALs and User CALs and when they've last used it.

      Regards,
      Herman

      • QVS API Support
        Deepak Kurup

        hi,

         

        1) If you ahve located QvsRefrence manul. then go to 65 page. it shows the different ways of Reloading. Or go to

        Management Console --> User Documents --> Reload --

         

        2) For Checking Document Cals See page no 67. for Document Cals or

        Management Console --> User Documents --> Document Cals--

        For User Cal go Licenses Tab -- > Licenses History. Will display you the history of people who has last access qlikview application.

         

  • QVS API Support
    Ashfaq Mohammed

    Hi Herman

    I have Monitoring App.

    You have to configure it on your server

    then you get all the details.

    Who is accessing what and what type of licensing they are using.

    Hope this will help you..

    Regards

    ASHFAQ

  • QVS API Support
    Stefan Bäckstrand

    Please, try and be more specific in your questions. There are three major versions of Qlikview that are currently released and supported - which one are you using?

    If you are using v10, make sure to install the Qlikview SDK, as a part of the Qlikview Server installation, where you can find full documentation for the QMS API; the Qlikview Server/Publisher API in v10.

    • QVS API Support
      hermandup

      Thank you. That was very helpful. I installed the SDK and looked at the samples and help DOCs. It still doesn't look like I will be able to get the licensing details from the QVS API. Can you confirm?

      My goal is to write a Windows Application in C# that will be used by selected high profile employees in our company to view QlikView license usage. The application should be able to tell the user who has doc CALs, user CALs etc. and their usage thereof.

      Will this be possible using the QVS API?

      • QVS API Support
        Stefan Bäckstrand

        You don't need any specific licensing to use the QMS API. You do however need to get the newest version of the web service reference from the QMS to be able to communicate with the API's. To do this; please right-click on the Web References node in the project explorer, select the QMSBackend service (or what it is named in your solution) and select Update (or such).

        When that is done, can you run the example? What is the error message? How far do you come?

        Regarding your second question; you can get all CAL data from QVS via the QMS API, yes. However, it is not possible to see user activity history via this interface - for that, you need to review the QVS session log, which logs all client CAL usage and such. I believe that a "mash-up" between these two might be the only way.

        • QVS API Support
          Skoezzi

          I did this and I get the error: "Service key is missing". (trying Taskconsole app in samples)

          • QVS API Support
            Stefan Bäckstrand

            Skoezzi; what version of Qlikview Server are you using? And are you using the web service from that servers QMS service?

            • QVS API Support
              Skoezzi

              I'm using version 10 R1. I changed the default QMS service to my servers QMS service without any problem. Its just giving 'service key is missing'.

              • QVS API Support
                Stefan Bäckstrand

                Skoezzi; I'm not sure what you refer to with R1 - is that IR (8715) or SR1 (8811, 8815)?

                Anyways; can you make sure that this step is done (from the API documentation in SR1 (8811))?

                 

                13. Add the following XML attribute to the bottom <endpoint ... /> tag of your app.config file: behaviorConfiguration="ServiceKeyEndpointBehavior"

                Also, make sure that the value of the constant SERVICE_KEY_HTTP_HEADER in the ServiceKeyClientMessageInspector.cs source file is X-Service-Key.

                 



                • QVS API Support
                  Skoezzi

                  Stefan,

                   

                  Thanks for the reply. I'm refering to SR1 8815.

                  I made those changes in my app.config & ServiceKeyClientMessageInspector.cs, but I still get "Service Key is missing".

                  • QVS API Support
                    Stefan Bäckstrand

                    Ok, the I would recommend that you walk through the steps in the documentation again, you'll find the chapter named "Service key injection sample" in there. You can find the documentation (.chm) under QEMC > System > Setup > Management Service (top node).

                • Re: QVS API Support
                  Venkatesh Kandasamy

                  Can anyone help me

                   

                  I am getting the following error when executing my project.

                   

                  The type 'Qv_License_Management.Service_Support.ServiceKeyBehaviorExtensionElement, Qv_License_Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'serviceKeyBehavior' could not be loaded. (C:\Users\e0615022\documents\visual studio 2010\Projects\Qv License Management\Qv License Management\bin\Debug\Qv License Management.vshost.exe.config line 12)

                   

                  Attached my project.

        • QVS API Support
          Pablo del Cerro

          Stephan,

          I´m trying to be able to add or remove a user from the Authorization List of a Document, have you ever tried that?

           

          I managed to get the list of documents, and the users that they have on Authorization, but i cannot figure out how to modify the DocumentMetaData.

           

          Thanks in advance!

          Pablo

          • QVS API Support
            Stefan Bäckstrand

            Pablo; you need to use the corresponding method SetDocumentMetaData. Extract the information from the API with GetDocumentMetaData, change the data, and re-insert it with the Set.. method.

            • QVS API Support
              Pablo del Cerro

              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

               

              • QVS API Support
                Amien Amien

                check my example Pablo

                • QVS API Support
                  Stefan Bäckstrand

                  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.



                  • QVS API Support
                    Pablo del Cerro

                    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

                    • QVS API Support
                      Stefan Bäckstrand

                      Use the GetUserDocumentNodes function. :)

                    • QVS API Support
                      hermandup

                      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





                      • QVS API Support
                        Stefan Bäckstrand

                        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);



                        • QVS API Support
                          Pablo del Cerro

                          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

                        • QVS API Support
                          Pablo del Cerro

                          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

                          • QVS API Support
                            Stefan Bäckstrand

                            This is not an object that's specifically a part of the API code - it's .NET behavior. You haven't defined that generic object lists should be of the type List<>, but Array[]. Array[] does not have .Add, but List<> does.

                            If you got to the Solution Explorer > (Project) > Services References > (QMS backend) > right click > Service Reference Settings.. > Collection type. Set this to "System.Collections.Generic.List" instead. You might need to re-build the solution for this (Ctrl+Shift+B).

                            You could as well use Array[] if you are more comfortable with that, but in my opinion it will only limit usage of API object lists, since List<> is a very powerful enumerable collection.

                            • QVS API Support
                              Pablo del Cerro

                              Thanks, that worked!

                              I´m sorry, i´m a newby at C#, and i´m doing my best to get this to work.

                               

                              Now, after changing that, when i start debugging, the instance of the BackEndClient throws me an error:

                              No se pudo cargar una sección de configuración de extremo para el contrato 'QMSBackendService.IQMSBackend' porque se encontró más de una configuración de extremo para dicho contrato. Indique la sección de configuración de extremo preferida por nombre.

                               

                              All i´m doing is: QMSBackendClient Client = new QMSBackendClient();

                               

                              Thanks

                              Pablo

                          • QVS API Support
                            hermandup

                            In the solution explorer, right-click the service reference to the API service and choose Configure Service Reference. Under Data Type, change the Collection Type to System.Collections.Generic.List

                          • QVS API Support
                            hermandup

                            In the solution explorer, right-click the service reference to the API service and choose Configure Service Reference. Under Data Type, change the Collection Type to System.Collections.Generic.List

                        • QVS API Support
                          a0284024

                          Hi Stefan,

                           

                          Do you know how to get the values of  Table inside the qvw files using the API?

                          I'm currently using qlikview 11 server and QMS api to retrieve the the document names and the server objects but i was not able to retrieve the values like the rows and column of the table object.

                           

                          Thanks,

                          Arnold

  • QVS API Support
    Amien Amien

    Dear herman,

    Check the attachment. It's a working example of how to get CAL licence information and deleting/quarantaine users. Using C++ and QVS API.

    Both named and document CAL's.

    it took me hours to figure this out! So some applause is welcome :)

    i'm sure i make more people happy with this!

     

     

  • QVS API Support
    vhuynh

    I'm also interested in the documentation for the management api. I can't find any documentation about the individual calls, parameters or results. Supposedly, everything that's available from QEMC is in the api but I haven't found anything for the list of user sessions and the documents that they have open.

     

    • QVS API Support
      Stefan Bäckstrand

      Every method, with parameter setup and expected return values and types in the QMS backend client is documented in the .chm help file which can be downloaded from the QEMC. Go to System > About, click on the node "Management Service" (top node) and you'll see the documentation link. If you download the file from a remote server, as in not localhost, make sure that you open the properties for the .chm file and click "Unblock" before opening it, otherwise pages in the file will be blocked, since it is not trusted if downloaded from a remote location.

      • QVS API Support
        hermandup

        Stefan, it seems like you know what you're talking about. Do you know how I can get the reload schedule for a document? I can get the Tasks for a document and I can see when the task was started and finished, but I need to see how it's scheduled.

        I've asked in a previous post, but didn't receive any helpful answers.

        Thanks

        • QVS API Support
          Stefan Bäckstrand

          Use the method GetDocumentTask(). It takes "DocumentTaskID" and "Scope" as parameters. You can get the Document task ID from a number of methods, but if you do not have it listed, you will probably have to go via GetSourceDocumentFolders, GetSourceDocumentNodes, GetTasksforDocument and then from there extract the task id and send into GetDocumentTask.

          • QVS API Support
            hermandup

            Thank you Stefan. It worked fine.

            I have another issues now. While I was developing the website, I could use the API. After I published the website, I get a "Forbidden" server error on the pages that uses the API. When I do a test to see who the current user identity is when running the website in the deployed environment, I get my username back so it should have worked.

            Do you have any ideas how I could solve this?

          • QVS API Support
            Pablo del Cerro

            Stefan,

             

            Thanks a lot for the help provided. I have succesfully created all the functions i need.

             

            The problem is that i have done them in C#, but i have converted it to VB because i need to mix it up with another code i already have. Now when i converted it to VB, i had to convert also the classes ServiceKeyBehaviorExtensionElement, ServiceKeyClientMessageInspector and ServiceKeyEndpointBehavior, but something seems to not work because the function QMSClient.GetServices(ServiceTypes.QlikViewServer) doesn´t get me an ID that i can then pass to the other functions.

             

            Do you have any ideas? Have you happened to work it out on VB?

             

            thanks

            Pablo

  • Re: QVS API Support
    sandravega

    I am also interested in finding out how to unassign a CAL programatically.  I am able to use the API to list the CALs but I can't find any methods to un-assign a CAL.  Below is how I am listing them:

     

    QMSBackendClient apiClient = new QMSBackendClient();

    ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();

    List<ServiceInfo> qvsServices = apiClient.GetServices(ServiceTypes.QlikViewServer);

    CALConfiguration NamedCALConfig = apiClient.GetCALConfiguration(qvsServices[0].ID, CALConfigurationScope.NamedCALs);
    CALConfiguration.CALConfigurationNamedCALs namedcals = NamedCALConfig.NamedCALs;


    foreach (AssignedNamedCAL cal in namedcals.AssignedCALs)
    {

         Console.WriteLine(String.Concat(cal.UserName, "|", cal.QuarantinedUntil, "|", cal.LastUsed));

    }

  • QVS API Support
    Venkatesh Kandasamy

    Hi Stefan,

     

    I am able to create and built a sample in console application but the same is not working in ASP.net application.

     

    Could you please provide a sample code or step by step guide using ASP.net application.

     

    especially step 10-13 in Qlikview Management API help file.

     

    Thank you.

    Venkatesh

  • Re: QVS API Support
    ahbenhayoun

    Hello everybody,

     

    Did someone find solution to add/remove user call via QMS API?

     

    Please share with us.

     

    Thanks a lot

    • Re: QVS API Support
      Scott Morris

      I did. Here is the sample code in C# I used to obtain a server key to browse the backend of the QMS API.

       

      This will LIST the Users and their last date accessed for Named Cals

       

      using System;

      using System.Collections.Generic;

      using System.Linq;

      using System.Text;

      using getCALs.QMSBackendService;

      using getCALs.ServiceSupport;

      using System.Threading;

      using System.IO;

       

      namespace getCALs

      {

          partial class Program

          {

              static void ListCALs()

              {

                  try

                  {

                      IQMS apiClient = new QMSClient();

                      ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();

                      ServiceInfo qdsService = apiClient.GetServices(ServiceTypes.QlikViewServer).FirstOrDefault();

       

                      CALConfiguration NamedCALConfig = apiClient.GetCALConfiguration(qdsService.ID, CALConfigurationScope.NamedCALs);

                      CALConfiguration.CALConfigurationNamedCALs namedCALs = NamedCALConfig.NamedCALs;

       

                      string mydocpath = @"Location to save the output of listed CALs"; // i.e. - \\QlikView\Storage\QVD

                      StringBuilder sb = new StringBuilder();

                      sb.AppendLine("UserName, LastAccessed");

       

                      foreach (AssignedNamedCAL cal in namedCALs.AssignedCALs)

                      {

                          sb.AppendLine(String.Concat(cal.UserName.Substring(9), ",", cal.LastUsed));

       

       

                          Console.WriteLine(String.Concat(cal.UserName.Substring(9), ",", cal.LastUsed));

                      }

                      using (StreamWriter outfile = new StreamWriter(mydocpath + @"\Users.csv"))

                      {

                          outfile.Write(sb.ToString());

                      }

       

                  }

                  catch(System.Exception ex)

                  {

                      Console.WriteLine("An exception occured: " + ex.Message);

                  }

              }

          }

      }

       

      Let me know if this helps you.  Make sure you create the references to the QMSBackendService under your Service References, etc.

       

      I also have code written to automatically remove anyone's license once they are no longer in the groups assigned to read QVWs AND are over 30 days since their last visit to the site.

      • Re: QVS API Support
        Arnold Ayaoan

        Hi Scott,

         

        I'm wondering if you used the GetFieldList method of this API already.

        Because I can't make the sample code on the documentation because it cannot find the below:

        ServiceTypes.QlikviewDistributionService

         

        Kindly help advice how to sort this out.

         

        Thanks,

        Arnold

  • Re: QVS API Support
    ahbenhayoun

    Hi Scott,

     

    Thank you very much for the code, it’s works very good.

    I’m very interested also by the code who remove licenses automatically.

    it's possible to share it with us?

     

    thanks