Qlik Community

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist
Specialist

Qlik Sense Mashup - using enigma.js in browser to connect to Engine API

Hi everyone,

I would like to be able to use the Engine API to create and retrieve bookmarks, but have no experience with the Engine API.  The syntax to make the request and the response seem straightforward, but I do  not know how to make the initial connection. I already have a session, so Ideally I would like to use the same session to open a connection to the Engine API.  I have read that enigma.js can be used and that enigma.js can be used through the browser, which would be my preferred option as I do  not have access to the server (other than through the dev-hub and QMC).

Can anyone help with a step-by-step guide, including any configuration and installation necessary  I am finding myself going from one topic to another on the Qlik help pages, without any complete examples. 

Thanks in advance.

Richard

1 Solution

Accepted Solutions
ErikWetterberg

‌Hi,

I have written on this in a blog post here:

https://extendingqlik.upper88.com/using-enigmajs-in-your-qlik-sense-extension/

BAsically Explorer the objects you get back from the API and look for the enigmaModel. Be aware that Qlik does not support this, so it might change in future releases.

Erik Wetterberg

https://extendingqlik.upper88.com/

View solution in original post

10 Replies
ErikWetterberg

‌Hi,

I have written on this in a blog post here:

https://extendingqlik.upper88.com/using-enigmajs-in-your-qlik-sense-extension/

BAsically Explorer the objects you get back from the API and look for the enigmaModel. Be aware that Qlik does not support this, so it might change in future releases.

Erik Wetterberg

https://extendingqlik.upper88.com/

rbartley
Specialist
Specialist
Author

Hi Erik,

Thanks once again for replying.  I have been able to access the enigmaModel and apply a bookmark using:

     app.model.enigmaModel.app.bookmark.apply(strBookMark)

But,  it appears that this only works when a login has previously been performed and the user authenticated.  However, I would like to be able to do this for anonymous users (or to automatically authenticate using a default user).  Any ideas?

rbartley
Specialist
Specialist
Author

p.s. I have been told that anonymous bookmarking should be possible using the Engine API methods CreateBookMark and  ApplyBookMark methods.

What I don't understand is, if we already have the engine-api-explorer (  http://<server>/dev-hub/engine-api-explorer ) , which allows us to communicate with the Engine API via the browser, why it isn't possible to interface with this to call the Engine API methods, e.g. by setting up a configuration, including the URL to connect to the Engine API and then call the method.  All of the documentation I have seen talks about the need to install enigma.js or an equivalent on the server.

ErikWetterberg

What happens when you try this? Is the bookmark public??

Erik Wetterberg

https://extendingqlik.upper88.com/

rbartley
Specialist
Specialist
Author

Erik,

I'm not sure what you mean when you ask "Is the bookmark public"?  Is it possible to make a public bookmark?  Can this be done by publishing the bookmark in some way that makes it available to anonymous users too?

Here's what I currently see:

When I have pre-authenticated by logging in to the dev-hub, the following returns  true:

     var promiseBookMark = app.bookmark.apply( strBookMark );

But when I'm not authenticated, it returns false

When I swap to:

    var promiseBookMark = app.model.enigmaModel.app.bookmark.apply( strBookMark );

I receive an error TypeError: Cannot read property 'apply' of undefined

p.s. Do you have an answer to my question above regarding the Engine API Explorer?

ErikWetterberg

Hi,

What I was refering to was published bookmark. Is the bookmark you are trying to apply newly created?

Haven't tried this but enigma is closer to the Eninge API (since it's auto generated), so it would probably be something like:

enigmaModel.app.getBookmark(strBookMark ).then(function(bm){

bm.apply();

});

Engine methods:

https://help.qlik.com/en-US/sense-developer/June2018/apis/EngineAPI/services-Doc-GetBookmark.html

https://help.qlik.com/en-US/sense-developer/June2018/apis/EngineAPI/services-GenericBookmark-Apply.h...

Erik Wetterberg

https://extendingqlik.upper88.com/

rbartley
Specialist
Specialist
Author

...I have found that app.model.enigmaModel.app.engineApp.getBookmark( strBookMark ) works fine when I am logged in, but returns the error below when not logged in.  The bookmark was created a few hours ago and is working as expected when logged in, but not when logged out.

getBookmark error.PNG

Any idea what error code 2 signifies?

rbartley
Specialist
Specialist
Author

Erik,

It seems that when not logged in, I can access only the bookmarks that have been created while logged in. 

rbartley
Specialist
Specialist
Author

Unfortunately, I cannot create or publish a bookmark as an anonymous user.

Although it seems at first glance that the bookmark has been created, the bookmark is, in fact, invalid.

When trying to publish the bookmark I receive an error:

    1. status: 2, value: Error: Forbidden at e.m (http://s-agri-qaptest1/resources/js/qlik.js:1:451496) at a (http://…}
    2. requestId:136
    3. then:ƒ ()
    4. __proto__:Object


I looked at this post: Allowing end users to create bookmarks on sheets

which meantioned a security rule:


Filter: App.Object_*

Action: Create

Conditions: !resource.App.stream.Empty() and resource.App.HasPrivilege("read") and (resource.objectType = "bookmark") and !user.IsAnonymous()

Context: Hub

Logic: Non-anonymous users can create app objects on apps which belong to streams where the user has read privileges already and the object that they are creating are bookmarks.




but it only relates to non-anonymous users, so I changed the condition to simply:


!resource.App.stream.Empty() and (resource.objectType = "bookmark")


and even just


(resource.objectType = "bookmark")



but this did not work either (same error on publish).


As such, I am stuck. I found this post Sharing Bookmarks | Qlik Community, but it only refers to allowing anonymous users to create bookmarks in QlikView, not Qlik Sense.


jvs‌  Yianni, do you have any ideas?