Azure Rest API giving AuthorizationFailed error and invalid_request error

I have tried two different APIs from different articles as shown below.

API 1

enter image description here

This API is working and token is getting generated.

Then in next part of API I am using generated token to fetch data:

enter image description here

But it is giving following error as shown in screenshot also.

{
    "error": {
        "code": "AuthorizationFailed",
        "message": "The client '**************' with object id '**************' does not have authorization to perform action 'Microsoft.Web/sites/read' over scope '/subscriptions/**************' or the scope is invalid. If access was recently granted, please refresh your credentials."
    }
}

API 2

enter image description here

But in this API, even token is not getting generated and giving following error

{
    "error": "invalid_request",
    "error_description": "AADSTS901002: The 'resource' request parameter is not supported. Trace ID: ************ Correlation ID: ************ Timestamp: 2023-12-28 07:17:52Z",
    "error_codes": [
        901002
    ],
    "timestamp": "2023-12-28 07:17:52Z",
    "trace_id": "************",
    "correlation_id": "************"
}

I searched but couldn’t find the solution. I want to fetch data from Azure active directory via Rest API. But that doesn’t seems to be working.

Leave a Comment