-
Notifications
You must be signed in to change notification settings - Fork 104
Closed
Closed
Copy link
Description
Describe the bug
When calling the API from either Invoke-MgGraphRequest or the Microsoft Graph Explorer it results into the following error:
{
"error": {
"code": "paymentRequired",
"message": "Payment Required. Ensure that your application is able to call this premium API.For details see https://aka.ms/graph-metered-overview",
"innerError": {
"date": "2025-04-02T07:35:50",
"request-id": "-",
"client-request-id": "-"
}
}
}
To Reproduce
Steps to reproduce the behavior:
- Create the App Registration
- Assign the
Sites.ReadWrite.AllandFiles.ReadWrite.Allpermission to the App Registration - Use the command in the AzureCloudShell to create the Billing Account: https://learn.microsoft.com/en-us/graph/metered-api-setup
- Get a successful back that the billing account is created.
- Authenticate with
Connect-MgGraph -NoWelcome -AppId $AppId -TenantId $TenantId - Run the API endpoint / PowerShell script below:
# Update the file's sensitivity label
$Uri = ("https://graph.microsoft.com/v1.0/drives/{0}/items/{1}/assignSensitivityLabel" -f $Drive.Id, $File.Id)
Try {
Invoke-MgGraphRequest -Method "POST" -Uri $Uri -Body $Body -OutputType PSObject
$Status = $true # set so that we report the update
Write-Host "Label updated to $($NewLabel.Name)"
} Catch {
$Error[0].Exception.Message
Write-Host ("Failed to assign sensitivity label to file {0}" -f $File.Name ) -ForegroundColor Red
}
Or in Microsoft Graph Explorer: https://graph.microsoft.com/v1.0/sites/{siteid}/drive/items/{itemid}/assignSensitivityLabel
7. Consent the following permissions: Files.ReadWrite.All and Sites.ReadWrite.All
8. Provide the following body:
{
"sensitivityLabelId": "REDACTED",
"assignmentMethod": "auto",
"justificationText": "test_justification"
}
- You will get the 402 Payment Required, even though I have the Premium Metered function applied.Expected behavior
The response should be HTTP/1.1 202 Accepted as I have followed the configuration steps which are available.
Desktop (please complete the following information):
- OS: Linux and Windows
- Browser Microsoft Edge
- Version 134.0.3124.95
Additional context
I would love to have a brief tutorial in setting this up so I can properly test the assignSensitivityLabel as now it is not working!
Reactions are currently unavailable