-1

In my flask project, there is a route:

def request_parse(req_data):
    if req_data.method == 'POST':
        data = req_data.json
    elif req_data.method == 'GET':
        data = req_data.args
    return data

@app.route('/api/d/u', methods=['POST'])
def update():  # name, domain_list, pem_key, pem_cert, origin_ips

    data = request_parse(request)
    name = data.get('name')
    domain_list = data.get('domain_list')
    pem_key = data.get('pem_key')
    pem_cert = data.get('pem_cert')
    origin_ips = data.get('origin_ips')

in Postman I request it like this:

enter image description here

I use postman request the api:

you see it is POST method, and in my project debug, I found the request data is in form,not in json.

enter image description here

I also tried form-data and x-www-form-urlencoded format, all are in form.

why postman POST method do not provide params to request.json? and is it possible to provide params in request.json?

1

1 Answer 1

0

If you want to send it as JSON, change from x-www-form-urlencoded to raw and you should see a drop down for Text, JSON, HTML. You can then select JSON

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.