Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading