Python requests returns 503 status code as response when sending a file through POST request

So I am using python requests to send a post request to another server (both servers are internal to the company). It worked some weeks ago, but I tried today and it has suddenly stopped working.

I can use postman to send the same request and the server responds with 201. I can perform a get request from my python code using requests library.

The problem ONLY occurs on post request from python code.

Here's the piece:

with open(filepath, "rb") as f:
        # f is a file-like object. 
        data = {"name": experiment_id + ".zip", "content": f}
        #The CALCSCORE_URL is an env variable named CALCSCORE_BE set up in each environment.
        calcscore_url = f"{settings.CALCSCORE_URL}/api/hive/experiment/{experiment_id}/roi" 
        response = request.post(calcscore_url, files=data)

I tried different things, like sending the data in a separate 'files' and 'data' argument but its always the same error. The file is 5 MB in size. I don't think its that big?

response.content shows response timed out.

Back to Top