[Python] Unable to parse arguments in Flask Restful for GET request

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    With reference to the below code, I am getting an error while parsing the parameters for a GET request in Flask Restful.

    from flask_restful import Resource, reqparse

    class View_Result(Resource):

    def get(self):

    parser = reqparse.RequestParser()
    parser.add_argument('aid', type=str)
    print('Here 1')
    data = parser.parse_args()
    print('Here 2')


    URL: http://127.0.0.1:8502/view_result?aid=1

    Console:

    Here 1
    127.0.0.1 - - [09/Nov/2022 01:52:43] "GET /view_result?aid=1 HTTP/1.1" 400 -


    Webpage:

    {
    "message": "Did not attempt to load JSON data because the request Content-Type was not 'application/json'."
    }

    Continue reading...

Compartilhe esta Página