Add new file in existing object using REST API

I have an object with some files.
Now I need to remove all files and add new file in that object.
 I can remove files using below Service

"http://localhost/REST/objects/{checkedOutObjectVersion.ObjVer.Type}/{checkedOutObjectVersion.ObjVer.ID}/{checkedOutObjectVersion.ObjVer.Version}/files/{checkedOutObjectVersion.Files[0].ID}.aspx?_method=DELETE"

Now I would like to add new file in that Object.

Upload new file in temp location.

{{url}}/REST/files

Now trying to update in document using below service


{{url}}REST/objects/
{checkedOutObjectVersion.ObjVer.Type}/{checkedOutObjectVersion.ObjVer.ID}/{checkedOutObjectVersion.ObjVer.Version}/files

But getting below response


What is the wrong I am doing

Parents
  • You can execute a POST to M-Files Web Service: Object files, including the new file content in the body as a stream.  The object must be checked out already and must be able to have another file added (e.g. by having the "single file document" property set to false).

  • That object is checked out and I just delete all files and need to update new files.
    Files are uploaded in temp location.
    When I am using UploadID and other details then getting this unnamed value

  • That approach is not supported.  As the documentation I linked to shows; you should push the file to the other endpoint instead.

  • Need to upload local file using this API

    So I upload file using this in Postman



    and now I need to use this response info to this API

    So I call this API with the upload info


    and result is Unnamed.

    I this process is right?
    or something wrong I did?

  • No, this process is not right.  You should upload the file as raw *directly* to:

    Fullscreen
    1
    {{url}}REST/objects/{checkedOutObjectVersion.ObjVer.Type}/{checkedOutObjectVersion.ObjVer.ID}/{checkedOutObjectVersion.ObjVer.Version}/files
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    No temporary upload file.

  • Still Unnamed

  • I just checking the code base, here 1st upload the local file to temp location in M-Files,

    Then pass that uploadInfo variable in API
    "/REST/objects/{objectType}/{objectId}/{versionString}/files/upload

    in updateInfo variable
    below data is stored

    =================================

    So in my postman call, Same URL, Same Title, Extension & Size to get the uploadInfo


    Then using that info to File Upload as like as line 507 in the code base you shared.


    What is the wrong I am doing?

  • Unfortunately I can't test this out for you right now.  By eye it looks like the sample code provides an array of UploadInfo instances and you provide just one, but that may not be the sole issue.

Reply
  • Unfortunately I can't test this out for you right now.  By eye it looks like the sample code provides an array of UploadInfo instances and you provide just one, but that may not be the sole issue.

Children