Forum Discussion
Failing: CloneTileInGroupAsync() in .NET API v2
- Anonymous4 years ago
Three weeks after I opened a support ticket on this, it finally got transfered to a team with REST API expertise. And they found the solution. When constructing a CloneTIleRequest object, we need to omit the target workspace id, and instead we need to include the target dataset id (which the class calls the "model ID"). So the object declaration should be:
var cloneRequest = new CloneTileRequest
{
TargetDashboardId = newDashboard.Id,
TargetReportId = targetReport.Id,TargetModelId = targetReport.DatasetId
};In my opinion the API documentation on this is incorrect. It says: “targetModelId - string - Optional. A parameter for specifying a target model ID. When cloning a tile linked to a dataset, pass the target model ID to rebind the new tile to a different dataset.” This implies that the parameter should not be sent if a tile is linked to a report not a dataset. Our support ticket would have been unnecessary if the documentation had described the purpose of this parameter correctly. See Dashboards - Clone Tile - REST API (Power BI Power BI REST APIs) | Microsoft Docs
I appreciate Microsoft support for showing us how to solve this. I wish Power BI REST APIs were better documented. And I really wish customers could get more usefull diagnostic information with API calls fail.
Liang,
We've now put the service principal directly into the Administrators role in the source workspace, and it continues to be an Administrator in the target workspace. We still get the same error.
Since you say our code looks correct, this appears to be a bug in the .NET Microsoft.PowerBI.API library. Perhaps it's a bug in the underlying REST API. Or the documentation may be incorrect or incomplete.
Can someone from Microsoft monitor our API calls and tell us exactly what is happening? As I said, the only information we get is an exception that says "Unauthorized". We tried calling Dashboards.CloneTileInGroupWithHttpMessagesAsync() but it just returns null. The inability to get detailed error information is one of our big frustrations trying to use the REST API from C#.