How do I implement a retry count of 5 times, 10 seconds apart when sending a POST
request using the requests
package.
I have found plenty of examples for GET
requests, just not post
.
This is what I am working with at the moment, sometimes I get a 503 error. I just need to implement a retry if I get a bad response HTTP code.
for x in final_payload:
post_response = requests.post(url=endpoint, data=json.dumps(x), headers=headers)
#Email me the error
if str(post_response.status_code) not in ["201","200"]:
email(str(post_response.status_code))