How to get the worksheet ID with the liveboard ID

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.
6 Replies
Sandeep Yadav
Sandeep Yadav2mo ago
Hi @Nikola Maletic : At the moment, there are two approaches you can use to obtain the worksheetId from a liveboard: 1. Metadata Search API
POST /api/rest/2.0/metadata/search
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:
{
"metadata": [
{ "type": "LIVEBOARD", "identifier": "<liveboard_id>" }
],
"include_details": true
}
{
"metadata": [
{ "type": "LIVEBOARD", "identifier": "<liveboard_id>" }
],
"include_details": true
}
• The response will contain metadata_details. • Look under:
metadata_details.header.resolvedObjects
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:
POST /api/rest/2.0/metadata/tml/export
POST /api/rest/2.0/metadata/tml/export
• Example payload:
{
"metadata": [
{ "type": "LIVEBOARD", "identifier": "<liveboard_name>" }
],
"edoc_format": "JSON",
"export_associated": true
}
{
"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
Nikola Maletic
Nikola MaleticOP2mo ago
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 { "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" } ] }
Sandeep Yadav
Sandeep Yadav2mo ago
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.<GUID>.resolvedObjects.reportContent.sheets[sheetContent.filter.filterContent.rows[column.referencedTableHeaders]
Nikola Maletic
Nikola MaleticOP2mo ago
Hmm 🤔, so worksheetId is fetched like?
No description
Sandeep Yadav
Sandeep Yadav2mo ago
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
Nikola Maletic
Nikola MaleticOP2mo ago
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: const extractedWorksheetTmlId = exportedData?.find( (item) => item?.info?.type === 'model' )?.info?.id; Thanks!

Did you find this page helpful?