-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?

user7693832
  • 6,119
  • 19
  • 63
  • 114
  • Does this answer your question? [Postman: sending nested JSON object](https://stackoverflow.com/questions/26705782/postman-sending-nested-json-object) – Quentin Jun 01 '21 at 15:29

1 Answers1

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

NoCommandLine
  • 5,044
  • 2
  • 4
  • 15