3 Replies Latest reply: Mar 27, 2014 11:54 AM by Desislav Tsankov RSS

REST API - creating a template on cascade

christian pabiou

Hi all,

 

I'd like to create a template on Cascade using REST API based on events.

I send my POST request (after successful authentication of course) with the following template:

{
  "name": "Trial Events",
  "live": "true",
  "sections": [
    {
      "widgets": [
        {
        "config": {
          "datasource": "EVENTS",
          "visualization": "TABLE",
          "widget_type": "CURRENT_EVENTS"
        },
        "widget_id": 1,
        "attributes": {
          "line_scale": "LINEAR",
          "line_style": "LINE",
          "width": 200,
          "height": 100,
          "orientation": "HORIZONTAL"
        }
      }
    ]
    }
  ]
}

When I send my POST, I receive the message saying "parsing failed: Error adding attribute live, value false at line 3, col 16, processed 44"

I checked the documentation but did not find any more details on the "live" parameter. Where can I find such info ?

 

PS: Once I have the template, I will create a report and probably have some questions later

 

Thanks

 

Regards

 

Christian

  • Re: REST API - creating a template on cascade

    The API supports only creating "live" templates (dashboards).

     

    Would creating a Dashboard solve your use case? The REST API will allow you to query for dashboard data as JSON/XML. It also allows getting the dashboard as CSV or PDF. Please let me know what your use case is and I can follow up with examples on how to solve it.

     

    Now to answer the specific question:

     

    The live property is bool, remove the quotes:

     

    - "live": "true"

    + "live": true

     

    This is not the only issue, here is a working POST to create a Dashboard with one widget - "Current events":

     

    {
      "name": "Trial Events",
      "live": true,
      "sections": [
        {
         "widgets": [
          {
           "title": "Current Events",
           "criteria": {
             "sort_column": 179,
             "sort_desc": true,
             "columns": [
               179,
               164,
               160,
               344,
               345,
               151
             ],
             "time_frame": {
               "data_resolution": "min",
               "type": "last_hour",
               "refresh_interval": "min"
             }
           },
           "attributes": {
             "colspan": 2,
            "n_items": 20
           },
          "config": {
            "widget_type": "CURRENT_EVENTS",
            "visualization": "TABLE",
            "datasource": "EVENTS"
          }
        }
      ],
      "layout": [
        {
         "flow_items": [
           {
            "id": 1
           }
         ]
        }
      ],
      "section_id": 1
      }
    ]
    }
    
    

     

    There is a factory with all the widgets that can be added to a Dashboard: GET $/templates/widgets.

     

    It would be easier to create the dashboard you want using the user interface and then get its JSON by doing GET $/reporting/templates/{ID}. To find out what is the dashboard (template) ID: GET $/reporting/templates.json?live=true