Hi @Pascal Kröger ,
I understand that you are receiving a 401 Unauthorized response when trying to access the Rest API.
The authentication also needs to be added to the staticwebapp.config.json, and the user needs to have the allowed role of authenticated or anonymous, as described here.
In addition, if you have linked a function app to your Azure Static Web App, I would recommend double-checking to ensure that the auth level of the function is explicitly set. I saw another user who faced this exact same error with the Data API Builder and the StaticWebAppsAuthCookie not completing the authentication. This was because the auth level of the function was not set explicitly and it defaulted to AuthLevel.FUNCTION
, even though AuthLevel.ANONYMOUS
was required in the simple auth flow.
Finally, I would recommend checking if the request includes a header with a key of X-MS-API-ROLE
and a value that matches a role name specified in your entity configuration rules, as shared by Deepanshukatara-6769 in the post.
Let me know if this helps and if you still face this issue.
If the information helped you, please Accept the answer. This will help us and improve searchability for others in the community who may be researching similar questions.