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.

3

1 Answer 1

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) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.