I’m using an HTTP activity to download an attachment from the ServiceNow portal. Over the past few days, it worked as expected and saved the file in the designated folder based on the properties panel settings.
However, recently the downloaded file has been getting corrupted after the download completes. Does anyone know what might be causing this issue?
@Ragul_Kannan I would suggest checking the below points:
Log the HTTP status code
Make sure the response is 200 OK.
If it is 401, 403, 404, etc., then the downloaded file is not the actual attachment.
Check the response headers
Verify Content-Type.
For a real file download, it should be something like binary/octet-stream or the actual file MIME type.
If it is text/html, application/json, or application/xml, then you are saving an error page/message as a file.
Do not hard-code the extension
In your screenshot, the file is saved as .xlsm.
Make sure the actual ServiceNow attachment is also .xlsm.
If the original file is .xlsx, .pdf, .csv, etc., saving it as .xlsm can make it appear corrupted.
Check authentication/session
Since it worked earlier and recently started failing, the token/session/permission may have changed or expired.
Try opening the same attachment URL in browser/Postman with the same credentials and confirm whether it downloads correctly.
Validate file size
Compare the downloaded file size with the actual attachment size in ServiceNow.
If the downloaded file size is very small, it is likely an error response, not the real file.
In my opinion, first log the status code, content type, and response body/size. That will clearly show whether UiPath is receiving the real attachment or an error response from ServiceNow.
Verify responseHeaders("Content-Type") and responseHeaders("Content-Length") → even with status 200, it might still return HTML (e.g. text/html → you’re downloading a login/error page)
Verify the file-extension. Mismatches can cause files to appear corrupted even if the content is correct
For better reliability and troubleshooting, consider creating a reusable template for your HTTP requests that includes:
Logging of critical information:
Status code
Response headers
Response size
Explicit handling of different status codes: 200 (ok), 201 (created), 409 (conflict, e.g. creating orchestrator assets, but they already exist)
Safe parsing of response data (e.g. JSON) using Try-Catch blocks in case fields are missing. Place them individually, so you definatelly know where the issues are
Throwing meaningful exceptions based on response conditions
Implementing retry logic where appropriate (e.g. for transient failures)
Could you try running the automation and checking the Windows Event Viewer and UiPath logs to see if any errors are reported during the download process?