String indices must be integers (dumb question)
Just setup a conversational bot (microsoft/DialoGPT-medium), and I’m trying to access it through the api url in some custom python code. My issue is that it tells me I need to include the content type if I give it the most basic of headers e.g.headers = {“Authorization”: f"Bearer {API_TOKEN}"}so that works. But when I add in the content type, I get {‘error’: ‘string indices must be integers’}this baffles me, it’s such a simple request, and everything I’ve researched tells me I’m making the request correctly. I know I’m just being dumb, but dagum I cannot find out why. Here is my codeheaders = {“Authorization”: f"Bearer {API_TOKEN}", “Content-Type”: “application/json”}def query(payload):data = json.dumps(payload)response = requests.request(“POST”, API_URL, headers=headers, data=data)return json.loads(response.content.decode(“utf-8”))data = query({“inputs”: “The answer to the universe is [MASK].”})print(data)
2023-04-28T22:50:29Z
having same error
2023-04-29T03:58:18Z
I have the same error too. I triedurl = "123456789"
headers = {
    "Authorization": "Bearer 123456789",
    "Content-Type": "application/json",
}
data = {"inputs": "This is a test sentence."}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
2023-04-30T18:20:39Z
can I see the full error code?