I made a curl in python to check some information from my client, it's happening okay, the answer from my api is json, I would like to know how to do if api has, for example "userId", it shows itself an "OK" on the console.
import requests
url = "https://minhaapi.com/v1/login/username"
querystring = {"countryCode":"BR"}
payload = "username=user&password=teste123&clientVersion=2.4.9-undefined"
headers = {
'Content-Type': "application/x-www-form-urlencoded",
'x-requested-with': "XMLHttpRequest",
'x-tidal-token': "wdgaB1CilGA-S_s2"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)
Resposta da minha API(Quando o usuário loga com as informações no curl):
{"userId":57261722,"sessionId":"5b1ada5b-addf-4804-a55e-a12f36959ff1","countryCode":"BR"}
I tried this code but could not:
for url in response.text:
if 'userId' in url.lower():
print ("OK")
I just want you to print on the "OK" screen when the curl shows the response in json above (that is when the user logs in), and if a different message appears, print "Error"