i want download an attached file on Creatio, using this endpoint:
https://miinstance.com/0/odata/ContactFile(f7946070-164d-48d3-8516-c31aff3f1588)/Data
But, don't work, If I consult directly without data, I receive the data, but to add /Data i receive the 204 status, y try with demo instance and works!, but in my production enviroment i always get the 204 status
{ "@odata.context": "https://astec.creatio.com/0/odata/$metadata#ContactFile/$entity", "Id": "cd7641f2-8e9f-00c5-6662-c68f0f2dd298", "CreatedOn": "2025-05-16T22:46:30.610332Z", "CreatedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00", "ModifiedOn": "2025-05-16T22:46:31.525903Z", "ModifiedById": "410006e1-ca4e-4502-a9ec-e54d922d2c00", "Name": "Abril 2025.pdf", "Notes": "", "LockedById": "00000000-0000-0000-0000-000000000000", "LockedOn": "0001-01-01T00:00:00Z", "TypeId": "529bc2f8-0ee0-df11-971b-001d60e938c6", "Version": 1, "Size": 135896, "ProcessListeners": 0, "ContactId": "35e409d2-c8fd-4790-9adf-43ff73abfc3e", "SysFileStorageId": "65e42805-0e6d-43c9-8784-32b555f08421", "FileGroupId": "efbf3a0d-d780-465a-8e4b-8c0765197cfb", "Tag": "", "TotalSize": 135896, "Data@odata.mediaEditLink": "ContactFile(cd7641f2-8e9f-00c5-6662-c68f0f2dd298)/Data", "Data@odata.mediaReadLink": "ContactFile(cd7641f2-8e9f-00c5-6662-c68f0f2dd298)/Data", "Data@odata.mediaContentType": "application/octet-stream" }
Like
Hello,
Here are a few possible reasons for this behavior and some directions on where to start the investigation:
1. A 204 response usually means the endpoint was found, but the file content is zero bytes. This can happen if the file wasn’t uploaded correctly or if there’s an issue with the file storage. You can confirm this by checking the file size directly in the database, for example:
SELECT DATALENGTH([Data]) AS Bytes
FROM ContactFile
WHERE Id = 'f7946070-164d-48d3-8516-c31aff3f1588'
If this returns 0, the problem is likely at the storage level, not the API.
2. In production, the file may be stored in an external location like AWS S3, Azure Blob, or a network share. In this case check the ActiveFileContentStorage system setting is correctly configured.
If your website is using an S3 storage and since it's an external storage there is no possibility to use OData to get files from it.
In this case we recommend to use a FileApiService in case you need to work with files on your website.
Nick Ovchynnik,
Nick Ovchynnik,
Hi Nick, I noticed that the storage is on S3, but I tried to create a web service with FileApiService to retrieve these documents attached to an object, but I wasn't successful. Not to mention creating a ScriptTask didn't work either.
Do you have a working example of how to do this?
Hi,
This article describes the operations with the files. Specifically, under the "Retrieve the file content" expandable tab.
If you face a specific issue with some part of the code, please submit a ticket to support@creatio.com so our team can address the error you got and suggest a solution.
Nick Ovchynnik,
Nick, finally i can make a webservice that, download a base64 of the selected document, let the code here, for help others with the same need.
Thank you very much.
namespace Terrasoft.Configuration.UsrFileRetrievalServiceNamespace { using System; using System.IO; using System.ServiceModel; using System.ServiceModel.Web; using System.ServiceModel.Activation; using Terrasoft.Web.Common; using Terrasoft.Core; using Terrasoft.Core.Factories; using Terrasoft.File; using Terrasoft.File.Abstractions; [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class UsrFileRetrievalService : BaseService { [OperationContract] [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] public string GetFileBase64(string fileId, string schemaName) { try { // Validaciones básicas if (string.IsNullOrEmpty(fileId) || string.IsNullOrEmpty(schemaName)) { return "Parámetros inválidos."; } Guid recordId = new Guid(fileId); // Creamos el localizador del archivo var fileLocator = new EntityFileLocator(schemaName, recordId); // Obtenemos la fábrica de archivos IFileFactory fileFactory = UserConnection.GetFileFactory(); // Cargamos el archivo desde la base de datos IFile file = fileFactory.Get(fileLocator); // Leemos el contenido del archivo byte[] content; using (Stream stream = file.Read()) { using (var ms = new MemoryStream()) { stream.CopyTo(ms); content = ms.ToArray(); } } // Convertimos a Base64 para retorno JSON seguro return Convert.ToBase64String(content); } catch (Exception ex) { return $"Error: {ex.Message}"; } } } }