I'm using some code that worked some months ago, it uses Flask and Flask_restful to work and I stumped upon something really extrange, the API doesn't work, but doesn't give me an error, from flask_restful I use reqparse to get the arguments, but whenever I use the method .parse_args() the response that I have to give doesn't pass through
code example:
class Ping (Resource):
def get(self):
parser = reqparse.RequestParser()
parser.add_argument ("lang")
# args = parser.parse_args()
return {
"message": "any message",
}, 200
response:
{
"message": "any message"
}
but when I use the parse_args() without even using the variable:
code:
class Ping (Resource):
def get(self):
parser = reqparse. RequestParser()
parser.add_argument("lang")
args = parser.parse_args()
return {
"message": "any message",
}, 200
response:
{
"message": "Failed to decode JSON object: None"
}
could someone explain what happens? what is happening?
I'm using python 3.8
I expected to have the message given in the code, but instead I have this message everytime, I tried different paths, rewriting the class, nothing worked, if someone knows a way to get through this or if someone knows a way to get the parameters of the url in some way it would be very helpful.