diff --git a/codeplain_REST_api.py b/codeplain_REST_api.py index 33542d2..5f5cf66 100644 --- a/codeplain_REST_api.py +++ b/codeplain_REST_api.py @@ -130,7 +130,14 @@ def post_request( for attempt in range(num_retries + 1): try: - response = requests.post(endpoint_url, headers=headers, json=payload) + response = requests.post(endpoint_url, headers=headers, json=payload, allow_redirects=False) + + if 300 <= response.status_code < 400: + # Treat redirects as a retryable error so a transient redirect retries as a real POST. + raise RequestException( + f"Unexpected redirect ({response.status_code}) to " + f"{response.headers.get('Location')} from {endpoint_url}" + ) try: response_json = response.json()