Skip to content

assignSensitivityLabel results in 402 even though Premium API in Azure is set-up #3756

@Karmakstylez

Description

@Karmakstylez

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:

  1. Create the App Registration
  2. Assign the Sites.ReadWrite.All and Files.ReadWrite.All permission to the App Registration
  3. Use the command in the AzureCloudShell to create the Billing Account: https://learn.microsoft.com/en-us/graph/metered-api-setup
  4. Get a successful back that the billing account is created.
  5. Authenticate with Connect-MgGraph -NoWelcome -AppId $AppId -TenantId $TenantId
  6. 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"
}
  1. 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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions