RestAPI, Bad Request


I’m trying to send some text to conversation integration over RestAPI (at the moment using python script), but I’m getting “400: Bad Request”.

import requests
import json

url = ''
headers = {
    'Authorization': 'Bearer my_long_lived_token',
    'content-type': 'application/json'
payload = {
        "text": "Turn all lights on"

response =, headers=headers, data=json.dumps(payload))

Can anyone spot the mistake?
PS: I’m quite new to coding so the whole thing might be misunderstood from my side.

Same thing happens to me, i cannot post any message. I even tried with “Curl” commands and i always getting: “Bad Reqeust: 400”

curl -X get -H "Authorization: Bearer ******* " -H “Content-Type: application/json” -d ‘{“entity_id”:“”}’ http://**********:8123/api/services/light/turn_on

I’m getting the same exact error message when using curl (from windows). I first thought this was a Windows-related issue. However, it looks like it’s caused by something else. Did anyone figure out what to do or did you give up? When I search for a solution on google, this thread pops up people with the same issue without a solution.

There was another person who had this same issue when using javascript to post. He said he had to add a JSON.stringify() to the body of the POST. I have no idea what that means when using curl.