Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

PowerBI Rest API synchronous call in C#

Hi Everyone,   I want to refresh mutliple datasets synchornously using Rest API in C#. 2nd dataset refresh should be called only after 1st dataset refresh gets completed, Challenge which i face rig...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Ted,

     

    Yeah you are almost right but we can use status column instead of start time / end time to identify whether API call got over or not. This is how I achieved it.

    IRestResponse response = client.Execute(request);
    var content = response.Content;

    string statusName = string.Empty;
    if (switchControl.ToLower() == "sync")
    {
    while (statusName.ToLower() != "completed")
    {
    statusName = GetRefreshHistoryByDatasetId(res.GroupId, res.DatasetId, token);
    if (statusName.ToLower() != "completed")
    {
    Thread.Sleep(sleepTime * 60 * 1000); //In minutes
    }
    if (statusName.ToLower() == "failed")
    {
    break;
    }
    continue;
    }
    }