Getting 400 Bad Request when passing a large String in Flask API request

Viewed 211

Might be a noob question, but I didn't find the solution anywhere else.

I have an API in Flask -

@app.route('/post-document-string', methods=['POST']) 
def parse_data():
    req_data = request.get_json(force=True)
    text = req_data['text']
    result = documentUtil.parse(text)
    return jsonify(keywords = result)

If I pass a String that is big enough, like 1000 words, it throws - 400 Bad Request

But if I pass a small String, like 200 words, it works fine.

My questions are -

  1. Does flask have a limit to how much data I can pass in request from frontend ? If yes, how to change it ?
  2. What is the best way in Flask API requests to pass a big String from front end ?
1 Answers

I think, there is a limitation in get_json method. Try this.

json_data = request.json
text = json_data['text']
Related