This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Adding a new file to an existing object (javascript)

Hi,

I succeeded to update an existing file attached to an object via the API "REST/objects/0/{checkedOutObjectVersion.ObjVer.ID}/files/{checkedOutObjectVersion.Files[0].ID}/content.aspx?_method=PUT", although that was tough. I need now to add a new file to an existing object. From the C# example at https://developer.m-files.com/APIs/REST-API/Updating-Objects/#updating-an-existing-file, I figured out that the API is "REST/objects/0/{checkedOutObjectVersion.ObjVer.ID}/{checkedOutObjectVersion.ObjVer.Version}/files/upload.aspx". However, it is not clear at all how I pass the file name and file extension through the API, mostly since I am using an application/octet-stream content type where I cannot mix JSON data and binary data.

Any help would be appreciated, as well as javascript examples.

Thank you in advance,

Gilles Gerlinger

Parents
  • By the way, this is the error message returned by the APi : "The current endpoint is part of the 'MFWA' extension. Use 'X-Extensions' header or 'extensions' query parameter to specify the extension."

  • To be more precise:

    This is the object sent after the file content is successfully uploaded:

    {UploadID: 4, Size: 1473469, FileInformationType: 0, Extension: 'zip', Title: 'SCORM_What_5G_is_and_what_it_isnt_TD10721-W-1800-kghuhxxs'}

    and the error message:

    {
      Status: 405,
      URL: '/objects/0/60893/latest/files/upload',
      Method: 'POST',
      Exception: {
        Name: 'NotSupportedException',
        Message: "The current endpoint is part of the 'MFWA' extension. Use 'X-Extensions' header or 'extensions' query parameter to specify the extension."
      },
      Stack: 'Error reference ID: 4e095967-d8d8-4d78-89e2-2118ee0901b3',
      Message: "The current endpoint is part of the 'MFWA' extension. Use 'X-Extensions' header or 'extensions' query parameter to specify the extension.",
      IsLoggedToVault: true,
      IsLoggedToApplication: true,
      ExceptionName: 'NotSupportedException'
    }

Reply
  • To be more precise:

    This is the object sent after the file content is successfully uploaded:

    {UploadID: 4, Size: 1473469, FileInformationType: 0, Extension: 'zip', Title: 'SCORM_What_5G_is_and_what_it_isnt_TD10721-W-1800-kghuhxxs'}

    and the error message:

    {
      Status: 405,
      URL: '/objects/0/60893/latest/files/upload',
      Method: 'POST',
      Exception: {
        Name: 'NotSupportedException',
        Message: "The current endpoint is part of the 'MFWA' extension. Use 'X-Extensions' header or 'extensions' query parameter to specify the extension."
      },
      Stack: 'Error reference ID: 4e095967-d8d8-4d78-89e2-2118ee0901b3',
      Message: "The current endpoint is part of the 'MFWA' extension. Use 'X-Extensions' header or 'extensions' query parameter to specify the extension.",
      IsLoggedToVault: true,
      IsLoggedToApplication: true,
      ExceptionName: 'NotSupportedException'
    }

Children
No Data