yellowbowlmigration
yellowbowlmigration

Reputation: 143

use postman to pass argument to flask always returns None

i want to use postman to pass parameters. however after i send POST request in postman, it always returns None for each parameter that i want to get . What did I do wrong?

@app.route('/', methods=['GET', 'POST'])
def Todo_all():

    ......

    if request.method == 'POST':
        title = request.values.get("title", type=str, default=None)
        description = request.values.get("description", type=str, default=None)
        return mytodo.create(title, description)

I have also tried

request.form.get
request.data

and I've tried print the value in console, and I get None as well

print request.form.get('title')

Upvotes: 2

Views: 2799

Answers (1)

Matt Healy
Matt Healy

Reputation: 18531

In Postman, make sure you're submitting the POST request with the content type of "x-www-form-urlencoded"

postman example

Upvotes: 3

Related Questions