1

I am trying to pass data via ajax POST to current py api but always get ImmytableMultiDict<[]> when try to print passed values.

Here is the code:

@app.route('/users/new', methods=['POST'])
@handle_exceptions_in_web_views
def intromeeting():
   print(request.args)
   firstname, lastname = parse_user_request_args(request.args)

def parse_user_request_args(args):

   firstname = args.get('firstName') or ''

   lastname = args.get('lastName') or ''

   return firstname, lastname

js code:

$.post('users/new', {

    firstName: 'test first name',
    lastName: 'test last name'

}).done(function(res){

    console.log(res)

}).fail(function (err){

    console.log(err)

}); 

I also tried to use $.ajax but got the same result. Should I move data to form or smth ?

Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
user1751287
  • 491
  • 9
  • 26
  • You should be using request.form instead of request.args . request.args is for url parameters. https://stackoverflow.com/a/16664376/8370670 – vishal Jul 06 '18 at 11:24
  • If you are sending it as JSON you could retrieve data from `.body` – Jimi Pajala Jul 06 '18 at 11:31

0 Answers0