Adding new lead label not working through Python

    url = "https://api.pipedrive.com/v1/leadLabels?api_token="+api_key
    headers = {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    }
    body = {
        "name": "test label Jan",
        "color": "yellow"
    }
    response = requests.post(url, headers=headers, data=body)```

This returns:
status: 400
response.text: bad request

Hey @Benjii
Welcome to the community :wave:

Can you try changing the data param to json when you perform requests.posts() call? I noted from the documentation of requests library that the body is form-encoded by default.

import requests
url = "https://api.pipedrive.com/v1/leadLabels?api_token="+"<api_token>"
headers = {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
}
body = {
      "name": "yellow label",
      "color": "yellow"
}
response = requests.post(url, headers=headers,json=body)

Thanks to @Nicole_Tan for pointing that out :slight_smile: