Kresten
Kresten

Reputation: 838

Send multiple parameters to flask-restplus

When creating an API that takes one argument from the request, I use this code:

class test(Resource):
    def get(self,id):
        return id

api.add_resource(test, '/endpoint/<int:id>')

What would I do if I need it to take multiple parameters?

I'm using python 3 and flask-restplus.

Any help is very appreciated!

BR Kresten

Upvotes: 2

Views: 1794

Answers (1)

Dinko Pehar
Dinko Pehar

Reputation: 6071

Flask-RESTPlus provides documentation for things that are unique to it. Everything other is documented in Flask, since Flask-RESTPlus is built on top of Flask.

In Flask (and Flask-RESTPlus of course ), you can use Variable Rules. And you can use it as many as you like:

class Test(Resource):
    def get(self, name, surname, age):
        return name + surname + str(age)

api.add_resource(Test, '/endpoint/<string:name>/<string:surname>/<int:age>')

But, consider using query arguments with RequestParser1 .

Upvotes: 2

Related Questions