Skip to main content
added 17 characters in body
Source Link
randomir
  • 18.8k
  • 1
  • 46
  • 60

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d '{"foo": "bar"}' -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

If running this on Windows (in cmd.exe, not PowerShell), you'll also need to change the quoting of your JSON data, from single quotes to double quotes:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d '{"foo": "bar"}' -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

If running this on Windows (in cmd), you'll also need to change the quoting of your JSON data, from single quotes to double quotes:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d '{"foo": "bar"}' -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

If running this on Windows (cmd.exe, not PowerShell), you'll also need to change the quoting of your JSON data, from single quotes to double quotes:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 
Use double quotes and espace internal ones.
Source Link
randomir
  • 18.8k
  • 1
  • 46
  • 60

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d "'{\"foo\""foo": \"bar\""bar"}"' -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

If running this on Windows (in cmd), you'll also need to change the quoting of your JSON data, from single quotes to double quotes:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d '{"foo": "bar"}' -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

If running this on Windows (in cmd), you'll also need to change the quoting of your JSON data, from single quotes to double quotes:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 
Use double quotes and espace internal ones.
Source Link

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d '"{"foo"\"foo\": "bar"\"bar\"}'" -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d '{"foo": "bar"}' -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 

According to the get_json docs:

[..] function will return None if the mimetype is not application/json but this can be overridden by the force parameter.

So, either specify the mimetype of the incoming request to be application/json:

curl localhost:5000/post -d "{\"foo\": \"bar\"}" -H 'Content-Type: application/json' 

or force JSON decoding with force=True:

data = request.get_json(force=True) 
Source Link
randomir
  • 18.8k
  • 1
  • 46
  • 60
Loading