How to get the worksheet ID with the liveboard ID
# help
n
Hello team, Our current workflow involves using the search API (api/rest/2.0/metadata/search) to retrieve all liveboards assigned to a user. We are now working on implementing Spotter for each liveboard. My difficulty is figuring out how to obtain the worksheetId that the Spotter SDK requires, given that we obtain our data from the search API. Is there a specific API where I can provide a liveboard and receive the corresponding worksheetId? Thanks in advance.
s
Hi @Nikola Maletic : At the moment, there are two approaches you can use to obtain the worksheetId from a liveboard: * 1. Metadata Search API*
Copy code
POST /api/rest/2.0/metadata/search
If the user has access to the metadata object, you can use the Metadata Search API. • Pass include_details = true in the request. • Example payload:
Copy code
{
  "metadata": [
    {
      "type": "LIVEBOARD",
      "identifier": "<liveboard_id>"
    }
  ],
  "include_details": true
}
• The response will contain metadata_details. • Look under:
Copy code
metadata_details.header.resolvedObjects
This lists all the questions used in the liveboard. • Each visualization may be built on different data sources. Traverse into: • reportContent.sheets[sheetContent.filter.filterContent.rows[column.referencedTableHeaders] • reportContent.sheets[sheetContent.filter.filterContent.rows[column.allLevelReferencedTableHeaders] These sections will tell you the source objects (worksheets/tables). For example, if a viz is created on Worksheet W1, and W1 is derived from Table T1, the response will show both W1 and T1. 2. TML Export API If the user has the DataDownload privilege, you can use the TML Export API: • Endpoint:
Copy code
POST /api/rest/2.0/metadata/tml/export
• Example payload:
Copy code
{
  "metadata": [
    {
      "type": "LIVEBOARD",
      "identifier": "<liveboard_name>"
    }
  ],
  "edoc_format": "JSON",
  "export_associated": true
}
• With export_associated = true, the API returns: • The liveboard TML • The associated data sources (worksheets and tables) as TMLs • Inside these TMLs, you can find the GUIDs for the worksheets and tables. Hope this helps
n
Hey Sandeep, thanks for the quick reply. I was using the first approach, but it looks like there is no straightforward method to get worksheetId without creating a bit of a dependency tree with the full object. Here is the request and response that I'm getting. Can you suggest to me the right field to use, the ID I'm looking for is b63aa6a1-260c-4ab7-8038-037e7bc02941
Copy code
{
  "dependent_object_version": "V2",
  "include_auto_created_objects": false,
  "include_dependent_objects": false,
  "dependent_objects_record_size": 50,
  "include_details": true,
  "include_headers": false,
  "include_hidden_objects": false,
  "include_incomplete_objects": false,
  "include_visualization_headers": false,
  "record_offset": 0,
  "record_size": 100,
  "include_stats": false,
  "metadata": [
    {
      "type": "LIVEBOARD",
      "identifier": "853c891b-a936-4595-8167-0f89092437fc"
    }
  ]
}
https://cdn.discordapp.com/attachments/1415268957677686824/1415655942657147021/message.txt?ex=68c3ffd6&is=68c2ae56&hm=998d38de8cf4aa1465156482288b95a87d2a1fbca332a742173fd92784337e2f&
s
Hi @Nikola Maletic : You can look for referencedTableHeaders and allLevelReferencedTableHeaders in the response — those should provide the data you need. This is also a valid use case for exposing these details upfront, rather than requiring a nested approach. If you could log this as an idea, the team can consider it for upcoming releases. Looping in @Nicolas for visibility on the use case.
metadata_details.header..resolvedObjects.reportContent.sheets[sheetContent.filter.filterContent.rows[column.referencedTableHeaders]
s
Yeah, this is a bit complex, but right now this can be done either via metadata/search or the TML APIs Just to update — we already have an include_dependent_objects attribute. When set to true, it returns the objects that depend on the given entity. At the moment, this only works when a logical_table is provided (i.e., it fetches all the answers and liveboards that depend on that table). Extending support for this attribute to Liveboard and Answer should address the problem. cc: @Nicolas@utsav.kapoor
n
Okay, so for the second approach, I should look for type=model in the array of objects that I'm getting from the response, like:
Copy code
const extractedWorksheetTmlId = exportedData?.find(
        (item) => item?.info?.type === 'model'
      )?.info?.id;
Thanks! https://cdn.discordapp.com/attachments/1415268957677686824/1417052570366513182/message.txt?ex=68c9148c&is=68c7c30c&hm=68216ce3571fac873624dea7472a76b31e02d1be112e4d029c697b73eb15747b&