Creating file in workspace with REST API:
PUT https://onelake.dfs.fabric.microsoft.com/{workspace}/{item}.{itemtype}/Files/sample?resource=file
Status code:401 Unauthorized
Error: Authentication Failed with Audience validation failed for audience 'https://analysis.windows.net/powerbi/api'
The application has all Power Bi permissions with consent still can't create a file.
Similar problem found here with no solution Creating OneLake files through REST API calls fail... - Microsoft Fabric Community
I generated one access token using client credentials flow with Power Bi scope like this:
Response:
When I used this token to create file in One Lake workspace, I too got same error as below:
Response:
In the registered application, I added Storage
API permissionas below:Now, I generated access token with Storage scope using client credentials flow via Postman like this:
Response:
When I used this token to create file in One Lake workspace, I got
201 Createdresponse like below:Response:
To confirm that, I checked the same in Portal where file created successfully in workspace like this: