Using REST API to add a version to a document

Hi, 
  Looking at the API documentation, it appears that creating a new document is supported (POST), as is updating the metadata on a document (PUT), but I cannot find an entry for appending a new version.  If the correct place is the PUT API (Update document), which field does the new file go into?
  While I'm asking, is it possible to specify the MIME type, or at least instruct Content Server in the AddVersion to *not* change the existing MIME Type? The use case is that a CSV file needs to be uploaded by API call to be processed by a WebReport. Since WebReports can take a CSV file as a data source only for the case of a static DAPI node, I need to have the leading application append versions to an existing node rather than upload a new file.  When I do this through the web UI, it always clobbers what I have preset for MIME type with the Microsoft-friendly MIME type for CSV files. WebReports can only deal with text/csv not application/vnd.microsoft-excel

Thanks in advance
-Hugh

Comments

  • Hugh, I did a POST on api/v2/nodes/DataId/versions.  As for the file I have a form with an objid text field and an input (type=file) field.  Also form has an enctype="multipart/form-data".  I have not tried to specify the MIME type.
    Cheers...
  • Hi John, 
      Yep, that was the ticket!  I should have searched for the versions API :blush: 
    When I just did the vanilla request, it made no attempt to update the MIME type so that works.

    -Hugh
  • John is right. You can try adding a new version using Smart UI and "spy" on the network communication too.

    The MIME type comes from the `Content-Type` header of the request body part with the file content. If code in JavaScript, you can change the `type` property of the file blob, before you add it to `FormData`. If it is a general type, it will work, vendor-specific types may require the application installed, which handles those file types.
  • Sowthri
    edited June 26, 2021 #5

    Hi,

    I suggest you to visit the below link where they have explained about the API Versioning.

    https://www.meritedin.com/blogs/api-versioning

    Please don't forget to check the videos listed in their playlist.


    Regards,


    Sowthri S

  • I think you're conflating document version and API version. This thread has nothing to do with the API version, but only the Content Server document version.

    -Hugh

  • Eduardo Rocher
    edited June 13, 2022 #8

    Comentario