0

I have the following code in C#:

request.AddParameter("application/json", "{\r\n \"content\": \"" + message + "\"\r\n}", ParameterType.RequestBody);

I want to convert that code to python. This is what I've got so far:

data = {
    'content': 'test'
}


r = requests.post(url, data=data)

I don't understand where the application/json part fits in.

1 Answers1

0

application/json is the content-type. You can specify the content-type of your request like this

headers = {
      'content-type': 'application/json'
    }

data = {
    'content': 'test'
}


r = requests.post(url, data=data, headers=headers)