Forum Discussion

Thor89's avatar
Thor89
Frequent Visitor
3 years ago

Setting workspace domain via API

Does anyone know if there is a way to set the new domain feature via the API?

I have more than 1300 workspaces to set and doing that by hand is not really an option.

I've seen that the domain info of a workspace is returned in the Metadata scanning in the API but I've not seen anything in the API documentation on setting the domain of a workspace.

9 Replies

  • Would you mind pointing to documentation about this new feature?

    • Thor89's avatar
      Thor89
      Frequent Visitor

      https://learn.microsoft.com/en-us/rest/api/power-bi/admin/workspace-info-post-workspace-info

      I run the metadata scan with all argumets set to true and the domain id is then included in that result set.

      Not sure which one of them adds it or it's part of the default execution I at least get it from this call.

      Example URL:

      https://api.powerbi.com/v1.0/myorg/admin/workspaces/getInfo?lineage=true&datasourceDetails=true&datasetSchema=true&datasetExpressions=true&getArtifactUsers=true

       

      Note that this will only get you the domain id of the workspaces that a domain has been set for. It does not allow you to set the domain. I've still not found an API way to do that. I ended up writing a bot to do it via the UI so that I could set the domain on all my orginizations workspaces.

      • bengtsson_peter's avatar
        bengtsson_peter
        Frequent Visitor

        Well, this is a bit wierd... I do the same thing. When I get to the step where I expand the column with the scan records, I only get these columns:

         

        BUT - if I after the expansion manually add "domainId", I do in fact get the domains!

         

        let
            Source = Result,
            workspaces = Source[workspaces],
            #"Converted to Table" = Table.FromList(workspaces, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
            #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1"{"id", "name", "type", "state", "isOnDedicatedCapacity", "domainId", "reports", "dashboards", "datasets", "dataflows", "datamarts", "users"}, {"workspace_id", "workspaceName", "type", "state", "isOnDedicatedCapacity", "domain_id", "reports", "dashboards", "datasets", "dataflows", "datamarts", "users"}),
          #"Changed column type" = Table.TransformColumnTypes(#"Expanded Column1", {{"workspace_id", type text}, {"workspaceName", type text}, {"type", type text}, {"state", type text}, {"isOnDedicatedCapacity", type logical}, {"domain_id", type text}, {"reports", type any}, {"dashboards", type any}, {"datasets", type any}, {"dataflows", type any}, {"datamarts", type any}, {"users", type any}})
        in
            #"Changed column type"

         

         

         

         

         

  • Hello,

    Any news here? Does anyone know if there's any way to automate domains related tasks (e.g. automatically create domains, automatically assign workspaces to domains, etc)?

    Thanks.