Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted November 7, 20231 yr Hi, I'm using the REST API to upload files I use the following endpoints: "index.php?/downloads/files" and "index.php?/downloads/files/{fileId}/history" (depending if I'm uploading a new version for an existent file or not) Anyway, regardless of the endpoint, all the files that I uploaded through the API are stored with a version date of "Released January 1, 1970" When I upload them via the website, the version date is stored properly, this only happens when I use the REST API to upload files Thanks Edited November 7, 20231 yr by BraCa
November 8, 20231 yr Author On 11/7/2023 at 2:13 PM, Marc Stridgen said: Please could you show the code you are using to upload those? Yes, but it's not PHP, it's written in C#, but here it goes var fileContentsAsByteArray = await File.ReadAllBytesAsync(filepath).ConfigureAwait(false); var fileContents = HttpUtility.UrlEncode(fileContentsAsByteArray); var body = new Dictionary<string, string> { { "category", request.CategoryId.ToString() }, { "author", request.AuthorId.ToString() }, { "title", HttpUtility.UrlEncode(request.Title)}, { "description", HttpUtility.UrlEncode(request.Description)}, { $"files[{request.Filename}]", fileContents}, }; if (!string.IsNullOrWhiteSpace(request.Version)) { body["version"] = HttpUtility.UrlEncode(request.Version); } if (!string.IsNullOrWhiteSpace(request.Changelog)) { body["changelog"] = HttpUtility.UrlEncode(request.Changelog); } var bodyString = body.ConvertToQueryString(); var uriPath = fileId.HasValue ? $"index.php?/downloads/files/{fileId.Value}/history" : "index.php?/downloads/files"; var response = await httpClient.PostAsync<UploadFileResult>( httpClient.BaseAddress, uriPath, bodyString, contentType: "application/x-www-form-urlencoded").ConfigureAwait(false);
November 8, 20231 yr Community Expert If you supply a date or updated value passed appropriately, do you get the same response?
November 9, 20231 yr Author 3 hours ago, Jim M said: If you supply a date or updated value passed appropriately, do you get the same response? I will try, but just to be clear, do you mean to add to the body new properties named "date" and "updated"? Also, in what format should those values be?
November 9, 20231 yr Community Expert Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release.
January 24, 20241 yr Community Expert Solution This issue has been resolved in the recently released 4.7.15 version. Please update your site if you are still experiencing the issue, and let us know if you see any reoccurrence.