Flask-RESTPlus - How to get query arguments?

12,965

Solution 1

I think the most correct solution I found is to use the request parser:

parser = api.parser()
parser.add_argument('user', location='args', help='Queried user')

It is discontinued from RESTPlus. But it is not going any time soon as they have mentioned.

Solution 2

It's a Flask plugin, it shouldn't be breaking the Flask interface. So you should be able to get them from flask.request as always:

import flask

...

print(flask.request.args.get("name"))
Share:
12,965
nikitz
Author by

nikitz

Updated on June 06, 2022

Comments

  • nikitz
    nikitz almost 2 years

    I'm curious how I can take query arguments coming from the GET method in Flask-RESTPlus. I didn't managed to find an example in the documentation.

    I have previously used pure flask and the way I was doing it was by calling 'request.args.get()' from the flask library. Any ideas how to achieve this in RESTPlus?