<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using Engine API to create new app for a specific user in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1659173#M12029</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Sorry if this is clearly explained somewhere - I can't find it, but it seems so straightforward.&lt;/P&gt;&lt;P&gt;I'm automating some of our work by building a Python library that interacts with the Qlik Sense Engine JSON API, using certificates that authenticate as an administrator.&lt;/P&gt;&lt;P&gt;Basically, what I am looking to do is create a new app (no problem), set an autogenerated load script (no problem), and assign it to a user determined on the fly [problem].&lt;/P&gt;&lt;P&gt;I don't see a parameter to set the owner/user of the app or to move it to a user's workspace.&amp;nbsp; It's not supposed to be published at this point and just be in their work stream.&amp;nbsp; How can I accomplish this?&amp;nbsp; I've searched through the&lt;A href="https://help.qlik.com/en-US/sense-developer/February2019/apis/EngineAPI/" target="_blank" rel="noopener"&gt; JSON Engine API docs&lt;/A&gt;, but there is very little about users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 03:47:10 GMT</pubDate>
    <dc:creator>kcrouse</dc:creator>
    <dc:date>2024-11-16T03:47:10Z</dc:date>
    <item>
      <title>Using Engine API to create new app for a specific user</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1659173#M12029</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Sorry if this is clearly explained somewhere - I can't find it, but it seems so straightforward.&lt;/P&gt;&lt;P&gt;I'm automating some of our work by building a Python library that interacts with the Qlik Sense Engine JSON API, using certificates that authenticate as an administrator.&lt;/P&gt;&lt;P&gt;Basically, what I am looking to do is create a new app (no problem), set an autogenerated load script (no problem), and assign it to a user determined on the fly [problem].&lt;/P&gt;&lt;P&gt;I don't see a parameter to set the owner/user of the app or to move it to a user's workspace.&amp;nbsp; It's not supposed to be published at this point and just be in their work stream.&amp;nbsp; How can I accomplish this?&amp;nbsp; I've searched through the&lt;A href="https://help.qlik.com/en-US/sense-developer/February2019/apis/EngineAPI/" target="_blank" rel="noopener"&gt; JSON Engine API docs&lt;/A&gt;, but there is very little about users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:47:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1659173#M12029</guid>
      <dc:creator>kcrouse</dc:creator>
      <dc:date>2024-11-16T03:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using Engine API to create new app for a specific user</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1659256#M12032</link>
      <description>&lt;P&gt;It is the repository that is responsible for this type activity, and the engine API is quite limited with regards to what functionality it exposes in this domain. A rule of thumb is that the engine is responsible for app contents, while the repository is responsible for app management. You can read more about the repository API here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/November2019/Subsystems/RepositoryServiceAPI/Content/Sense_RepositoryServiceAPI/RepositoryServiceAPI-Introduction.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense-developer/November2019/Subsystems/RepositoryServiceAPI/Content/Sense_RepositoryServiceAPI/RepositoryServiceAPI-Introduction.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;with the reference here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/November2019/APIs/RepositoryServiceAPI/index.html" target="_blank"&gt;https://help.qlik.com/en-US/sense-developer/November2019/APIs/RepositoryServiceAPI/index.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;To set owner of an app you would probably use this endpoint:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense-developer/November2019/APIs/RepositoryServiceAPI/index.html?page=692" target="_blank"&gt;https://help.qlik.com/en-US/sense-developer/November2019/APIs/RepositoryServiceAPI/index.html?page=692&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2019 07:22:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1659256#M12032</guid>
      <dc:creator>Øystein_Kolsrud</dc:creator>
      <dc:date>2019-12-19T07:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Engine API to create new app for a specific user</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1660109#M12043</link>
      <description>&lt;P&gt;Aha!&amp;nbsp; Thanks so much, Yko!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll be planning to explore that this week!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 13:33:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1660109#M12043</guid>
      <dc:creator>kcrouse</dc:creator>
      <dc:date>2019-12-23T13:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using Engine API to create new app for a specific user</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1661123#M12054</link>
      <description>&lt;P&gt;Hi everyone, I have now had a chance to explore the QRS in depth and have found two ways to accomplish this.&amp;nbsp; For those who may come upon this thread in the future, these features should be able to be extrapolated to (a) other objects that aren't Apps and (b) other fields besides owner as well.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Set up:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In both options below, I am assuming you have fetched the App JSON through one of various methods, such as GET to /qrs/app/{id}&amp;nbsp; or GET to /qrs/app/full with various parameters.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;Option 1:&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#3366FF"&gt;Create A Selection and Modify Just the Field you are Interested in&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;First option 1, you will need at least the hexidecimal app id&amp;nbsp; and the modifiedDate from the App JSON. The Modified Date is critical - if it's not the exact same date as the app, this will fail. This prevents a race condition in which a field is updated by one user between when another one gets the app's info and attempts to update it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 1&lt;/STRONG&gt;: Create a new "selection" entity via a POST&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;POST&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;/qrs/selection&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;with data along the following lines :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "items":[ {
       "type": "App",
       "objectID": "{hex_app_id}",
  }],
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That will return a new selection json object, and you will want the *&lt;STRONG&gt;id*&amp;nbsp;&lt;/STRONG&gt;value from that , which below is {selection_id}&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2&lt;/STRONG&gt;: Send the update&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PUT to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;/qrs/selection/{selection_id}/app/synthetic&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;with data along the lines of :&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;{
  "properties": [{
      "name": "owner",
      "value": {new_owner_hex_id},
      "valueIsModified": True
  }],
  "type": "App",
  "LatestModifiedDate": {app_modified_date_and_time},
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 3: Delete the Selection&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;DELETE to /qrs/selection/{selection_id}&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Option 2: Do a direct update of the object itself&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;This method grabs the app's full json and performs a REST update via a PUT call. It's simpler in that you don't have to deal with selections, but it can be a bit less obvious what's going on if you are inspecting the data.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 1: Create the json object with your updates.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The json object&amp;nbsp;&lt;/STRONG&gt;MUST INCLUDE the last&amp;nbsp;&lt;STRONG&gt;modifiedDate&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&amp;nbsp;&lt;STRONG&gt;modifiedByUserName&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;. So, if you had gotten the app data by calling&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;/qrs/app/{hex_app_id}&lt;/FONT&gt;, it will be those returned fields.&lt;/P&gt;&lt;P&gt;Aside from those, you can add any fields you want to update and replace. There's clearly a hierarchy of fields. I have tested it with only adding in the owner "id" and putting in an incorrect "name", and everything was set based on the ID.&lt;/P&gt;&lt;P&gt;Alternatively, it's fine to leave in fields that aren't changed, as well. If you are lazy, you can get the full app json, just modify the desired fields in place, and submit the entire json entity back in the put statement.&lt;/P&gt;&lt;P&gt;Here's an example of a json payload that only modifies the owner information:&lt;/P&gt;&lt;PRE&gt;{
    'modifiedByUserName': {last_modified_by_user_name}, 
    'modifiedDate': {last_modified_date}, 
    'owner': {
         'id': {user_hex_id} 
         'userDirectory': {user_directory}, 
    }
}&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2: PUT to&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;/qrs/app/{hex_app_id}&lt;/FONT&gt;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with data set to your json payload.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2019 20:53:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Engine-API-to-create-new-app-for-a-specific-user/m-p/1661123#M12054</guid>
      <dc:creator>kcrouse</dc:creator>
      <dc:date>2019-12-27T20:53:15Z</dc:date>
    </item>
  </channel>
</rss>

