Forum Discussion
Get workspace components git status through API call
Contributor role on the workspace
Hi amaaiia,
Can you show me the exact POST request that you're sending? A 400 error usually means that your request is incorrect. Microsoft's APIs are particularly picky when it comes to the parameters and body.
If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
- amaaiia10 months agoSkilled Sharer
The POST request should be ok because if I change the Bearer token with a token of my personal account, I get 200 OK:
If I use service principal token, then I get 400:
But the POST request is the same.
- tayloramy10 months agoSuper User
amaaiia Thanks for the info, so something is up with the service principal.
How are you generating the bearer token?
Can toy also confirm what delegated permissions the service principal has?
Here's my function for generating the bearer token using the MSAL librarydef get_access_token(): app = ConfidentialClientApplication( CLIENT_ID, authority=AUTHORITY, client_credential=CLIENT_SECRET, ) result = app.acquire_token_for_client(scopes=SCOPE) if 'access_token' in result: return result['access_token'] else: error = result.get('error', 'No error information') error_description = result.get('error_description', 'No description') raise Exception(f"Could not obtain access token. Error: {error}. Description: {error_description}")If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
- amaaiia10 months agoSkilled Sharer
I get the token with: https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token
{ "method": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "body": "grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>&scope= https://analysis.windows.net/powerbi/api/.default " }
And it works because I'm using it for other Fabric API calls such us: https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/{element_type}
These are API permissions, doc says GitUpdate is enough: