0

I'm using flask_restful and using reqparse to get params as an example:

from flask_restful import Resource, reqparse

path_params = reqparse.RequestParser()
path_params.add_argument("city", type=str)
path_params.add_argument("star_min", type=float)
path_params.add_argument("star_max", type=float)
path_params.add_argument("diary_max", type=float)
path_params.add_argument("diary_min", type=float)
path_params.add_argument("limit", type=float)
path_params.add_argument("offset", type=float)

       data = path_params.parse_args()
// returning error here : "message": "Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)"

What can I do to solve this, please?

1 Answer 1

1

What you are seeing is the error when json.load or (json.loads) receives an empty JSON document to decode.

import json

json.loads("")
# raises JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Without more of your code and especially request you sent, we cannot tell you more about your problem.

But, if I run the full example from the Flask-RESTful docs and request an empty JSON doc, I get the same error.

curl http://localhost:5000/todos -H "Content-Type: application/json" -d '' -X POST
{
    "message": "Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.