HTTP Request: The request timed-out

Hi, I am trying to send a file from ‘Wait for download’ activity using HTTP Request, When I checked logs from API, it shows that I sent the request without problem:

2024-08-22 03:46:05,946 - INFO - File upload attempt - id: 1, Filename: test.pdf, Size: 107.15 KB, Duration: 0.00 seconds

08/22/2024, 03:46:08 AM - INFO - “POST /api/v1/test/upload/file HTTP/1.1” 200 OK

But when I check from job logs I see these:

An error occurred during the HTTP request: The request timed-out.
HTTP Response: , Status Code: 0

What could be wrong?

HTTP Request Wizard:

Test API endpoint using FastAPI:

@app.post("/api/v1/test/upload/file")
async def upload_file(
    id: str = Form(...),
    file: UploadFile = File(...)
):
    start_time = time.time()
    file_content = await file.read()
    duration = time.time() - start_time
    file_size_kb = len(file_content) / 1024  # Byte to KB conversion
    duration_seconds = f"{duration:.2f}"  # Format duration to 2 decimal places

    logger.info(f"File upload attempt - id: {id}, Filename: {file.filename}, Size: {file_size_kb:.2f} KB, Duration: {duration_seconds} seconds")

    await asyncio.sleep(2)  # 2 seconds sleep

    return JSONResponse(content={"message": "File upload information logged"}, status_code=200, headers={"Content-Type": "application/json"})

Note: in_file_path is actually file.FullName

Note2: I confirmed that I can send file successfully but why I receive time-out error from UiPath?

@gururaser,

Try changing the timeout to 60000.

Thanks,
Ashok :slightly_smiling_face:

@ashokkarale, thanks for answering.

But this is not solution I desire, I don’t think so it will change something even it does I don’t want my automation to take an extra minute.

@gururaser,

It will not add delay if your API call gets executed before the timeout.

Timeout is just the maximum time the activity will wait before throwing an exception.

Thanks,
Ashok :slightly_smiling_face:

Hi, of course I know but I see logs in my api side immediately while time out in UiPath

Hi @gururaser

For some more hints, I would suggest using a dummy file and then sending the same request via both:

  • the working method
  • UiPath activity

to a service like this one:

or

This way you can visually compare both requests, and see if maybe there are some crucial differences to be aware of.

At first look, it might be a bug in the activity not properly “understanding” that the request was successful, but I cannot say it with certainty just yet. This is why the above test would be super helpful.

@loginerror Hi, thank you for message

1- What is the working method?
2- When I tried with “webhook.site” everything worked properly. So does it indicate that there is problem with my FastAPI code?

update: Yes!! Problem was with my API. I fixed it now everything work properly.

1 Like

Hi,
so from UiPath you are sending a request to the python fast api code and that request is getting timed out correct?

can you have your fast api return a basic response code just 200 and check
or just have a basic func for checking connectivity between fast api and UiPath. A python func that just returns hello world.

edit: NVM, saw your update.

1 Like

Thank you for trying help!!

I’m glad it worked out. These services I linked are meant to simply retrieve the request and visually display it to help with debugging, which seems to have helped :slight_smile:

I wouldn’t send anything sensitive to those services, but I often find myself mocking some data and quickly testing things this way to see that everything is working as it should.

I agree, even though they say that they delete the data. We should be careful with these kind of situations. Unfortunately sometimes it becomes hard to find data looks like original one and it makes everything harder.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.