<Response [400]> when sending api get request with json body to an api deployed on google app engine

Viewed 35

I'm working on a school assignment where I've created a simple api to read and add data to a firebase database. We've tried it locally and it works fine. Now, I'm trying to deploy it to google app engine and I've encountered a very annoying issue. If I set the argument inside of the function (as is now commented out), I get a valid response. But if I try to enter a json body and parse it with RequestParser, I get a <Response 400>. Does anyone know why this works locally but not once it's deployed to google app engine? If anything is unclear, I'll be happy to clarify!

def get(self):
    parser = reqparse.RequestParser()
    parser.add_argument("name",type=str,help = "name of recipe or ingredient is required",required = True)
    args = parser.parse_args()
    #args = dict({"name":"Carbonara"})

    if(args["name"] == 'all'):
        hej = getCollection()
        return {'data': hej},200

    recipes = getRecipes(args["name"])
    if(recipes != None):
        return recipes,200
    result = recipeContains(args["name"])
    if result != []:
        return result,200
    return "No results"

response = requests.get("https://cohesive-photon-346611.ew.r.appspot.com/recipes", {"name":"Carbonara"})

response = requests.get("https://cohesive-photon-346611.ew.r.appspot.com/recipes")
0 Answers
Related