Getting username blank error with API Authorization

Trying to connect to the REST API using POST /api/session to authorize.

Getting error:
{"errors":{"username":"value must be a non-blank string."}}

Steps to Reproduce

  1. Run jar file
  2. Sign into Metabase
  3. Open Python
  4. Execute the following:

url = "https://localhost:3000/api/session"

payload= {}
headers= {
  'username': '_email@email.com_',
  'password': '_password_'

response = requests.request("POST", url, headers=headers, data = payload)


I Have Also Tried

  • Used Postman to send the call. Same error
  • Switching Headers and Payload in Python request. Results in SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')])
  • Used curl to send the call (curl -X POST -d "Content-Type: application/json" -H '{"username": "", "password": "password"}' http://localhost:3000/api/session) . Same error
  • Switched -d and -H in curl: curl -X POST -H "Content-Type: application/json" -d '{"username": "", "password": "password"}' http://localhost:3000/api/session. Same error
  • Removed Content-Type header: curl -X POST -d '{"username": "", "password": "password"}' http://localhost:3000/api/session. Same error.

Metabase Version

  • Metabase 0.35.3
  • Using jar file

Finally got it to work in Postman.

I added the following to the body:

BTW, there are already three Python wrappers for Metabase API (here, here and here).

1 Like

If anybody else stumbles upon this - the way the request needs to be formatted is

url = "https://localhost:3000/api/session"
json= {
  'username': '_email@email.com_',
  'password': '_password_'

response =, json = json)

I initially tried the headers as well. Thanks to the wrapper @King_Edward linked to it was easy to grab the actual request format that is current!