Questions tagged [flask-restful]

Flask-RESTful provides an extension to Flask for building REST APIs. Flask-RESTful was initially developed as an internal project at Twilio, built to power their public and internal APIs.

Project repo is maintain on Github currently.
The latest document is here
Its pypi info can be find here

1619 questions
9
votes
4 answers

Flask API failing to decode JSON data. Error: "message": "Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)"

I'm setting up a simple rest api using flask and flask-restful. Right now all I'm trying to do is create a post request with some Json data, and then return it just to see if it works. I always get the same error "message": "Failed to decode JSON…
FProlog
  • 173
  • 1
  • 1
  • 9
9
votes
3 answers

Object of type 'ObjectID' is not JSON serializable

I am having what appears to be a common problem but so far I can't see a solution that applies to me. I think I'm just missing something small but I've broken down to ask for help. I am trying to get json output using flask and pymongo. here is…
Nicholas Elliott
  • 339
  • 1
  • 2
  • 11
9
votes
1 answer

Flask API not receiving requests all of a sudden

I am trying to create a REST API in Flask. The thing is it runs perfectly for a few days and then all of a sudden it STOPS receiving requests altogether. Forget about not responding to requests; it just doesn't receive any requests at the first…
90abyss
  • 7,037
  • 19
  • 63
  • 94
9
votes
2 answers

GET with and without parameter in flask-restful

The following strikes me as inelegant but it works. Is there a way to have flask-restful handle the two standard flavors of get (i.e. get everything and get one item) using the same resource class? Thanks. from flask_restful import Resource #…
John Lockwood
  • 3,787
  • 29
  • 27
9
votes
3 answers

'400 Bad Request' when post json in Flask

My application is very simple, #@csrt.exempt @app.route('/preorders/json', methods=['POST']) def json_create_preorders(): #print request print 'test' #print request.json print request.mimetype print request.json print…
Xiaokun
  • 814
  • 2
  • 10
  • 26
9
votes
5 answers

Parsing a list of integers in flask-restful

I'm using the flask-restful, and I'm having trouble constructing a RequestParser that will validate a list of only integers. Assuming an expected JSON resource format of the form: { 'integer_list': [1,3,12,5,22,11, ...] # with a dynamic…
Ricardo
  • 7,921
  • 14
  • 64
  • 111
9
votes
1 answer

Flask: Creating objects that remain over multiple requests

I've been able to create objects that are created at every request from this link: http://flask.pocoo.org/docs/appcontext/#locality-of-the-context. I'm actually creating an API based off of…
John
  • 3,037
  • 8
  • 36
  • 68
9
votes
4 answers

Flask-Restful error: "as_view" method not inherited

I am writting a RESTful API using the Flask framework and the Flask-RESTful plugin. I define my API classes on top of the Resource class that this plugin provides, as in the examples. However, when I want to register my classes using the…
9
votes
1 answer

Securing Flask-Restful API with OAuth2

Okay, so I wrote an API using Flask-Restful and now I want to implement OAuth2 authorization. I've tried pyoauth2, but it's undocumented and the tutorial is quite complicated. So, my question is: How do I do that?
Ale
  • 1,998
  • 19
  • 31
9
votes
2 answers

How to parse the POST argument to a REST service?

It seems I have another JSON problem, this time when posting to the REST service. I am using Flask-Restful. api.add_resource(Records, '/rest/records///') parser =…
Houman
  • 64,245
  • 87
  • 278
  • 460
8
votes
1 answer

TypeError: wrapper() got an unexpected keyword argument 'nam' while using @jwt_required

app.py from flask import Flask,request from flask_restful import Api , Resource from flask_jwt import JWT ,jwt_required , current_identity from security import auntheticate , identity app = Flask(__name__) app.secret_key = "sangam" api =…
ChangeAdopter
  • 81
  • 1
  • 2
8
votes
2 answers

ImportError: cannot import name 'generate_password_hash'

from flask import jsonify from flask import flash, request from werkzeug import generate_password_hash, check_password_hash Error Please help me to fix these issues I have tried with pip install Werkzeug But not working Traceback (most recent call…
8
votes
4 answers

"Not enough segments" when seding a GET message with Bearer Token Authorization Header (flask_restful + flask_jwt_extended)

I got this error in Flask Application: curl http://0.0.0.0:8080/ -H "Authorization: Bearer TGazPL9rf3aIftplCYDTGDc8cbTd" { "msg": "Not enough segments" } Here a sample: from flask import Flask from flask_restful import Resource, Api from…
Andre Araujo
  • 2,348
  • 2
  • 27
  • 41
8
votes
3 answers

Flask-Swagger-UI does not recognize path to swagger.json

I'm building an API, using Flask and flask-restful and flask-swagger-ui. I have now modified the project structure and now I can no longer access the project's swagger.json file. Based on the package documentation flask-swagger-ui, you would only…
vic.py
  • 409
  • 10
  • 22
8
votes
2 answers

Using flask_login and flask-JWT together in a REST API

I am new to flask, recently learned about flask_security/flask_login/flask_user. I wish that somehow I could use flask_login along with flask-JWT, for the REST API. Basically, I'd like to have the features like remember-me, forgot-password etc,…
penka_the_cow
  • 81
  • 1
  • 4