API request 401,even though i used error username,also return 401 rather than error username

i met 401 when i use api requests a few days ago,it looked like it was rejected .Even though i used error acount password,it did not return reponse like invalid username or password.

Probably to prevent someone from guessing and figuring out the user name or password

Can you show us what you are using? Is it python script?

I used this to test and i view logs on the server console.

curl -H "Authorization: Bearer mytoken" https://myIP/api/org
logger=context userId=0 uname= t=2024... level=info msg= error="[auth.unauthorized]" cannot authenticate request traceID=

What version of grafana. And which documentation did you use for this approach

The version of grafana is 11.1.3.I reffer to documentation with the link ‘HTTP API | Grafana documentation’

I confirmed the configuration of api

[api]
enabled = true

That is for old version see this

Also missing a few items

-H “Content-Type: application/json”

Etc

I added -H “Content-Type” ,but it did not work.it looked like the request won’t be
Authorized with the url contained ‘/api’

Post exactly what you did minus ip and token

1 Like

even though i used error token or use error account, it always return like the picture says

What is this error token error account?

What do you want it to return other than 401

As we can know,if i use error account ,itwould return like ‘Invalid username or password’.I notice that just want to help to figure out the problem,it is not important.