Get PAT using Rest API

I am trying to get list of PAT created for an user account. But getting the below error
ValueError: Failed to authenticate: Content-Type ‘application/json’ is not supported

Actually, we are trying to create PAT using API. why PAT has only 180 days, do we have the flexibility to extend the expiry?
To create, get PAT through REST https. do we need to set any parameters in setting?

#python snippet:
USERNAME = ‘xxxx’
PASSWORD = ‘xxxxxx’

API endpoint for authentication

auth_endpoint = f’{DREMIO_URL}/apiv2/login’
headers = {‘content-type’:‘application/json’}

Payload for authentication

auth_payload = {
“userName”: USERNAME,
“password”: PASSWORD
headers = {
response =, headers=headers, json=auth_payload, timeout=10)

auth_token = response.json().get(‘token’)

API endpoint to create a personal access token

pat_endpoint = f’{dremio_url}/apiv2/token’

Payload to create a personal access token

pat_payload = {
“label”: “My Personal Access Token” # You can set a label for your token

Headers for the request, including the authentication token

headers = {
‘Authorization’: f’_dremio{auth_token}',
‘Content-Type’: ‘application/json’

Create the personal access token

response =, headers=headers, json=pat_payload)

Our docs have a note that says the following:
You cannot view tokens for another user. Tokens may only be viewed for the user performing the API call.