Sisense Community logo
    • Community Feedback
    • Chapters
    • Events
    • Forums
      • Help and How To
      • Product Feedback Forum
      • Strategy & Use Cases
    • Blogs
    • KB Docs
      • KB Docs
      • Add-Ons & Plug-Ins
      • APIs
      • Best Practices
      • Blox
      • CDT
      • Cloud Managed Service
      • Data Models
      • Data Sources
      • Embedding Analytics
      • How-Tos & FAQs
      • Onboarding
      • PySisense
      • Security
      • Sisense Administration
      • Sisense Intelligence & AI
      • Troubleshooting
      • Widget & Dashboard Scripts
    • Support
    • Learning
      • Sisense Academy: Free Courses and Certifications
      • Official Developer Documentation
      • Official Product Documentation
      • Official Sisense Youtube Channel
      • Sisense Compose SDK Playground
    • Use Case Gallery
    All PostsDiscussionsBlogsIdeasQuestions
    Leaderboards
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Discussions
    • Knowledge Base DocsChevronRightIcon
    • APIsChevronRightIcon
    Get Widget’s Values Directly From The ElastiCube (API Request)
             
    Description
    Shifting between external sources that are based on different scripting languages is not an easy task. When there is a requirement to query a secured widget's data to an external source (Such as JQuery, JavaScript,HTTP etc.), you will need to utilize the REST API. 
    A quick example will be grabbing a widget's data to a public website or a customized company's mail report.
    Prerequisites 
    1. Sisense Admin permission
    2. REST API Access 
    3. ElastiCube and linked dashboard with widgets
    4. PostMan application installed - https://www.getpostman.com/apps
    5. Granted access to the machine (IP) that is going to execute the API request against the Sisense Server - Check that the dashboard is accessible from the external machine that execute the API request.
    Steps
    a. Widget's JAQL Preparation and Save it
    1. Make the the JAQL code as short as possible by "starring" the formulas that are used in the widget - https://docs.sisense.com/main/SisenseLinux/reusing-formulas.htm
    2. To get the widget's JAQL code - Edit Widget > Click on F12 to open developer tools > Open Console > Clear Content > type -
      prism.debugging.GetJaql(prism.activeWidget).replace(/(\r\n|\n|\r|\t)/gm, "");
      and then hit enter
    3. Copy the JAQL code to notepad - without the quotes
    b. Create the Curl and URL Request 
          1. Go to the Admin Page > Click on REST API reference > Open REST API 0.9 (top right of the screen)
          2. Go to - Post> elasticubes/{elasticube}/jaql
          3. Copy the JAQL code into the request's body 
          4. Copy the ElastiCube ID from the JAQL code (data source section) into the ElastiCube input without the quotes. For example:
    5. Hit Run and validate the response. A correct response will appear in bottom:
    6. Copy the Curl and Request URL to notepad: 
    c. Create authentication token to query the ElastiCube
          1. Go to the Admin Page > Click on REST API reference >  Open REST API 1.0 (top right of the screen)
          2. Go to - Post> authentication/login
          3. Insert your username/password and hit execute 
    4. Copy the given access token from the response section without quotes to notepad 
    d. Generate the Final API Request 
             1. Open PostMan and create a new POST request
             2. Enter the Request URL - Place Sisense Request URL and ElastiCube ID taken from the step B.
             3. Copy the the body tab (choose raw option) the entire JAQL code from step A.
    4. Open Authorization tab > choose Bearer type > Insert your authentication token from Step C.
    5. Open Headers section and add:
    Content-Type, application/json 
    Accept, application/json
    6. Hit send to get the API call response that will include your widget data values
    Response Example:
    7. Click on "code" (right side of the page), to covert the API request to any scripting language that is required.
    intapiuser
    By
    intapiuser
    Posted 3 years ago·Last reply 1 year ago
                                           
             
    2 comments

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                   
    Tim von Ahsen

    Tim von Ahsen

    ·1 year ago

    Hi vishalbhomia89, I had a similar error and solved it:
    For me, the cause was that my Sisense URL was like "www.mydomain.com/Something/app/...". When you set "/api/elasticube/<id>/jaql" as the URL in your script, Sisense/JavaScript will implicitly prepend the domain. So, my path becomes "www.mydomain.com/api/...".
    The URL needs to include the "/Something". There are two ways to do that:
    (A) URL = "/Something/api/elasticube/<id>/jaql".
    (B) URL = window.prism.proxyurl + "/api/elasticube/<id>/jaql".

    I prefer (B) because my script gets run on multiple Sisense instances with different URLs, so having it dynamically deal with the "/Someting" or "/SomethingElse" is good for me.

                                           
    vishalbhomia89

    vishalbhomia89

    ·3 years ago

    Hi intapiuser ,

    I am also doing something similar, but can not find the endpoint where we are querying the JAQL.

    The /api/elasticube/<id>/jaql does not exist for me. If I go to the admin page I can not see that under REST API. Am  missing something?

                                           
                                                                                     
    •                                                              
    •                                                              
    •