3 Replies Latest reply: Jun 14, 2017 3:03 AM by Øystein Kolsrud RSS

    Cloning app through qlik sense .net sdk

    Dario Balestri

      Hi all!

      We are going to need a great amount of preinitialized apps, therefore we've been thinking about cloning them programmatically.

      We found a method that looks perfect for our needs (https://help.qlik.com/en-US/sense-developer/3.2/apis/net%20sdk/html/M_Qlik_Engine_Hub_CopyApp.htm), but failed at making it work. It takes a third argument which is a list of the guid's of the elements to be copied into the new app. It's default behaviour when an empty list is provided, I quote, is that it "copies only the data and the objects necessary to open the app" - so no sheets get copied, though we want those too!

      We tried doing few things, like using all the guids of objects inside the app, that results in an error n. 9003, engine id not found.

       

      Here is a short code sample (yes, we already know that the app to be copied into must already exist, and is to be created before the cloneapp function is called):

       

      IAppIdentifier srcAppId = _location.AppsWithNameOrDefault(srcAppName).First();
      List<string> ids = _location.App(srcAppId).GetAllInfos().Select(info => info.Id).ToList();
      IAppIdentifier newAppId = _location.CreateAppWithName(newAppName);
      _location.Hub().CopyApp(newAppId.AppId, srcAppId.AppId, ids);
      

       

      The resulting error is

      Qlik.Engine.MethodInvocationException: 'Resource not found [9003]:Resource not found(Engine ID not found)'

       

      I can post the logs too, if you think it's necessary. Please, any help is appreciated. Thanks

      DRB

        • Re: Cloning app through qlik sense .net sdk
          Øystein Kolsrud

          I think the recommendation would be to use the repository API for this type of operations. You might want to check out these endpoints:

           

          App: Export app (call 1 of 2) ‒ Qlik Sense

          App: Export app (call 2 of 2) ‒ Qlik Sense

          App: Import app ‒ Qlik Sense

           

          I think approach will be a more robust than going through the engine API. You might for instance risk some issues relating to sense versions if you try to move apps between different servers. If you go through the repository, then the app version migration should be taken care of automatically.

           

          If you want the copies on the same server, then you also have this endpoint to work with:

           

          App: Make copy ‒ Qlik Sense

            • Re: Cloning app through qlik sense .net sdk
              Dario Balestri

              Mh, okay thanks.

              I must admit I'm not very enthusiastic about your answer, since I already knew about the repository api, and authenticating through them looks to me to be much more of a pain than the simple:

              _location.AsNtlmUserViaProxy(uri.Scheme.Equals(Uri.UriSchemeHttps), new NetworkCredential(user, pwd, domain), false);

               

              Moreover I won't need this to copy apps between different servers, so using the engine doesn't look that risky to me. Isn't really there any way to make the CopyApp method work? It even explicitly asks for a guid list, which I provided, so I really don't know how that possibly manages to fail.

              Any idea?

               

              In the meanwhile I'll look into authenticating via the repository API, though reluctantly.

              Thanks again anyway!

              Dario

                • Re: Cloning app through qlik sense .net sdk
                  Øystein Kolsrud

                  I must admit that I have never used the CopyApp method you refer to ,myself, but my guess is that it is being used by the repository as part of the copy operations. At least the description of the CopyApp method seems to indicate that:

                   

                  "The engine copies the app into an app entity that was previously created by the repository. See the QRS API (REST API) help for more information."

                   

                  Apart from that, I think there are a number of solutions relating to this topic available on Qlik Branch. This, for instance, was the first hit I got when I searched for "clone app":

                   

                  Sense app duplicator