3

I'm trying to test a form created using wtform in flask using postman. In the form I have a FieldList of StringFields and I have specified minumum entries = 2. I have tried different solutions to test validations from postman, but always validation fails. I have tried testing by removing the fieldlist, the form validation works properly. I'm unable to send data as a list of stringfields from postman in x-www-form-urlencoded keyvalue format. Code Snippets:

class PostUserForm(Form):
    email = StringField('email', [validators.DataRequired()])
    name = StringField('name', [validators.DataRequired()])
    words = FieldList(StringField('words',[validators.DataRequired()]), min_entries=2)


@apiV1.route('/user', methods=['POST'])
def post_user():
    form = PostUserForm(request.form)
    print request.form
    if form.validate():
        return jsonify("correct data"), 200
    else:
        return jsonify(form.errors), 400

Following are Solutions I tried: enter image description hereenter image description hereenter image description hereenter image description hereOutput:Output same for all solutions

Ameya Kulkarni
  • 198
  • 1
  • 2
  • 14

1 Answers1

3

Finally found out how to do that, following screenshot shows the sample requestenter image description here

Ameya Kulkarni
  • 198
  • 1
  • 2
  • 14
  • you should’ve clarified that you changed `words` to `keywords` in `PostUserForm` :) – hadi Jun 06 '21 at 09:19