Creating a poll

Hey Guys
I´m trying to create polls via the api

header = {
    "Authorization":"Bearer <my auth>",
    "Client-Id":"<my client id>"}

params = {
    "broadcaster_id":"<a user is>",
    "title":"test",
    "choices":[
        {"title":"1"},
        {"title":"2"}
        ],
    "duration":"15"
}

res = requests.post(url="https://api.twitch.tv/helix/polls", headers=header, data=params)

print(res.text)

That´s my short test script

But I get this response

{“error”:“Bad Request”,“status”:400,“message”:“Missing required parameter “choices””}

I´m confused because it says that this parameter is missing but it is in the params variable.

Can anyone help me?

You attempted to POST as a FORM and the Params are incorrect.

Try POSTing as JSON instead of FORM encoding

1 Like

Thank you it worked

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.