I am trying to make a python request and proceed with the script when the response status code is 200. Else, keep looping through until I get 200.
Tried the following statements not sure what I am missing here. The condition does not exit the loop.
Try 1:
while True:
if (offense_response.status_code == 404):
time.sleep(5)
logging.info("Status code is 404, entering sleep for 5 seconds")
offense_response = requests.get(qradar_offense_url, headers=q_headers, verify=False)
continue
if (offense_response.status_code == 200):
logging.info("Status code is 200, exiting loop")
exit()
Try 2:
while (offense_response.status_code != 200):
if (offense_response.status_code == 404):
logging.info("Status code is 404, entering sleep for 5 seconds")
time.sleep(5)
offense_response = requests.get(qradar_offense_url, headers=q_headers, verify=False)
else:
logging.info("Status code is 200, exiting loop")
Try 3:
while True:
if (offense_response.status_code != 200):
time.sleep(5)
logging.info("Checking Response Status Code again")
offense_response = requests.get(qradar_offense_url, headers=q_headers, verify=False)
if (offense_response.status_code == 200):
break
offense_response?ifwith a single comparison?