Jump to content

Downloads - REST API - Version date is not set


Go to solution Solved by Marc,

Recommended Posts

Posted (edited)

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 by BraCa
Posted
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);

 

Posted
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?

Posted

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.

 

  • 2 months later...
  • Solution
Posted

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...