Home > database >  the answer to my request does not give the same string as the one displayed
the answer to my request does not give the same string as the one displayed

Time:10-19

I am making a call to an api, the return of the answer gives me a string (that I print)

however when I want to do a check, it doesn't work

there is my code:

def get_status_stripe_dependencies():
    request = requests.get("https://status.stripe.com/current/full")

    if request.status_code != 200:
        return (False)    
    

    request_json = (request.json())
    reponse = (request_json["message"])
    reponse = str(reponse.strip())
    print("reponse", reponse, "aas")


    if ("All Services are online") in reponse:
        return True

    return "WHYYYYYYYYYY"

my print gives me "All Services are online" BUT MY return is "whyyyyyyyyyyy"

I tried to remove invisible chars but it doesn't work if someone has the solution.

Thanks for yours answers

CodePudding user response:

The S of Services is in uppercase and the response returned this string All services are online, so you may change your test to:

if "all services are online" in reponse.lower():
        return True
  • Related