Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

A programmatic way to retrieve "workspaceHead" value required by UpdateFromGit API

The UpdateFromGit API requires "workspaceHead" and "remoteCommitHash" in the body.  It's easy to figure out the remoteCommitHash from the git log which is the last commit of the repository.  But it is tricky for the workspaceHead.  My company's Git Integration setup have one Git repository and multiple workspaces from PBI mapped to respective folders within the same repo, so each workspace's head is different.  I can see the workspace head value displayed in the PBI service UI when I access each workspace.  We need a programmatic way for us to get that value for different workspaces, as we are trying to automate the process (through scripting) which pulls down the committed changes inside the Git repo and sync to the Power BI service.  Or better yet, if this API can be enhanced - since we are already providing the workspace ID in the API call, it should automatically figure out the workspaceHead for that id behind the scene, so we don't have to figure it out with coding and provide it in the body.  


curl --location 'https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/git/updateFromGit' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data '{
"workspaceHead": "4a480a507fc051a009fd52a412a6be3c9909b603",
"remoteCommitHash": "e75bd9ba6db14fabc2d25895e4e83fe8c9bfb260",
"conflictResolution": {
"conflictResolutionType": "Workspace",
"conflictResolutionPolicy": "PreferRemote"
},
"options": {
"allowOverrideItems": true
}
}'

Status: New
Comments
osancus
New Member
You can use the endpoint GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/git/connection it will give you the response { "gitProviderDetails": { "organizationName": "Test Organization", "projectName": "Test Project", "gitProviderType": "AzureDevOps", "repositoryName": "Test Repo", "branchName": "Test Branch", "directoryName": "" }, "gitSyncDetails": { "head": "eaa737b48cda41b37ffefac772ea48f6fed3eac4", "lastSyncTime": "2021-11-20T09:26:43.153" }, "gitConnectionState": "ConnectedAndInitialized" } the "head" is what you are looking for. Docs can be found here https://learn.microsoft.com/en-us/rest/api/fabric/core/git/get-connection