API Error: TypeError: string indices must be integers

Viewed 86

I'm really new to StackOverflow.

I want to create a Pterodactyl Client Panel using Python. But if I want to get the servers Info on the Panel it shows me this:

Traceback (most recent call last):
  File "system_server.py", line 16, in <module>
    print(resp['data'])
TypeError: string indices must be integers  

My Code:

import json
import requests
import configuration
url = 'https://client.blutudlut.xyz/api/application/servers'
headers = {
    "Authorization": "Bearer "+ configuration.pterodactyl_admin_api,
    "Accept": "application/json",
    "Content-Type": "application/json",
}

response = requests.request('GET', url, headers=headers)
print(response.text)
json_str = json.dumps(response.text)
resp = json.loads(json_str)
print(resp)
print(resp['data'])

I tried many ways but it's always the same problem.

0 Answers
Related