Search code examples
c#unauthorizedazure-analysis-services

Azure Analysis Service Rest API Error - Status 400 (Bad Request) with "unauthorized" message


I am trying to call the Azure Analysis Service API, to refresh my model, using this documentation as a reference, (https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-async-refresh#post-refreshes) and I'm getting this error:

{
    "code": "Unauthorized",
    "subCode": 0,
    "message": "An internal error occurred.",
    "timeStamp": "2021-06-09T16:04:46.0645307Z",
    "httpStatusCode": 400,
    "details": [
        {
            "code": "RootActivityId",
            "message": "f2f92034-12f2-4dac-8910-db89797150f6"
        },
        {
            "code": "Param1",
            "message": "asazure://asazureeus22-aspaaseastus2.asazure.windows.net/...."
        }
    ]
}

As you can see, the StatusCode is 400 (Bad Request), although the error message is unauthorized.

If, for example, a change the token that I'm using to an invalid one, I receive this message, with statusCode 401. (which makes sense)

{
    "code": "Unauthorized",
    "subCode": 0,
    "message": "Authentication failed.",
    "timeStamp": "2021-06-09T16:09:52.682502Z",
    "httpStatusCode": 401,
    "details": [
        {
            "code": "RootActivityId",
            "message": "8755550d-caf8-4789-91a4-2a4f567c9dd0"
        }
    ]
}

So, I believe that my token is valid, but something wrong is happening "inside" the AAS.

Can anyone help me to identify what exactly is this error?

Thank you.


Solution

  • This error occurs when the user (or service principal) does not have a server admin role on the Analysis Service.

    So I add my service principal as Analysis Services Admins, and it is working now!