Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send POST request using flask.redirect?

I'm trying to create a flask service in which I want to send the data coming from one request.form to another url in json format, Please can anyone help me to achieve this?

redirect(url_for('any_method'), json = json.dumps(my_form_dict))

When I try to execute the above code I'm getting following error:

TypeError: redirect() got an unexpected keyword argument 'json' The above is the error here.
like image 474
Mukunda M Mhasalkar Avatar asked Oct 21 '25 12:10

Mukunda M Mhasalkar


1 Answers

You can redirect POST requests using 307 status code. Use:

redirect(url_for('any_method', json=json.dumps(my_form_dict)), code=307)

For more information refer to this answer: Make a POST request while redirecting in flask

like image 150
ReemRashwan Avatar answered Oct 23 '25 01:10

ReemRashwan