How to use REST API to get Recovery Services Vault Security PIN?

Nathan Given 26 Reputation points
2024-05-15T15:16:17.9366667+00:00

I'm trying to use this API to programmatically get the security pin for my recovery services vault. The endpoint is documented here:

https://learn.microsoft.com/en-us/rest/api/backup/security-pi-ns/get?view=rest-backup-2023-02-01&tabs=HTTP

But I'm getting this error:

{
    "error": {
        "code": "CloudInvalidInputError",
        "message": "The current operation failed due to an internal service error \"Invalid input error\". Please retry the operation after some time. If the issue persists, please contact Microsoft support.",
        "target": null,
        "details": null
    }
}

Has anyone seen this error? My efforts to solve the problem haven't yielded any results yet. Any help in resolving this issue would be appreciated.

Here's the process I'm following:

Step 1: POST to https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token

My POST body includes

  • client_id = "{client_id}"
  • client_secret = "{client_secret}"
  • grant_type = "client_credentials"
  • scope = "https://management.azure.com/.default"

Step 2: Get access token from previous response, create authorization header

  • Authorization = "Bearer {access_token}"

Step 3: Make a GET request to https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.RecoveryServices/vaults/{vault_name}/securityPIN?api-version=2023-02-01

It is at this point I get the CloudInvalidInputError.Thank you~!

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,143 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SadiqhAhmed-MSFT 39,136 Reputation points Microsoft Employee
    2024-05-15T19:04:39.6033333+00:00

    @Nathan Given Thank you for posting your question.

    I see that you are using REST API to get Recovery Services Vault Security PIN and being greeted with an error message.

    The error message that you are receiving indicates that there is an issue with the input that you are providing to the API. Here are some things that you can check to resolve the issue:

    1. Make sure that you are using the correct values for the placeholders in the URL. Double-check the subscription ID, resource group name, and vault name to ensure that they are correct.
    2. Make sure that you have the necessary permissions to access the resource. Check that your client ID has the appropriate permissions to access the Recovery Services vault.
    3. Check that the API version that you are using is correct. The API version that you are using is 2023-02-01. Make sure that this is the correct version for the API that you are using.
    4. Try using a different tool or method to access the API. For example, you can try using Azure PowerShell to access the API and see if you get the same error message.

    For you reference: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.recoveryservices.backup.securitypinsoperationsextensions?view=azure-dotnet-legacy&viewFallbackFrom=azure-dotnet

    Hope this helps!


    If the response helped, do "Accept Answer" and up-vote it

    0 comments No comments

  2. Nathan Given 26 Reputation points
    2024-05-15T22:52:14.9166667+00:00

    @SadiqhAhmed-MSFT I figured it out. The URL is:

    https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/SwaggerTest/backupSecurityPIN?api-version=2023-02-01
    

    not

    https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/SwaggerTest/securityPIN?api-version=2023-02-01
    

    (I forgot the word "backup" in the URL).

    It is also a POST, not a GET.