cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in creating document using SAP BTP DMS API'S from CAPM nodejs project

jigar_salecha
Explorer
1,090

Hello All,

We are trying to post a document in BTP DMS using BTP DMS API's from our nodejs CAPM project but unfortunately it creates a document in BTP DMS with corrupted content so unable to read it.Attaching screenshot for reference -

We tried passing the document as bas64string, unitArray, buffer, PDFdoument but nothing works.It creates the document without giving any error but created document is not readable.Below is the nodejs code snippet -

async function _createDocument(sFolderName, folderCreateURL, filedata) {

var formData = new FormData();

// formData.append("objectid", sFolderName);

formData.append("cmisaction", "createDocument");

formData.append("propertyId[0]", "cmis:name");

formData.append("propertyId[1]", "cmis:objectTypeId");

formData.append("propertyValue[1]", "cmis:document");

formData.append("_charset_", "UTF-8");

formData.append("includeAllowableActions", "true");

formData.append("succinct", "true");

formData.append("propertyValue[0]", filedata.fileName);

formData.append("filename", filedata.fileName);

formData.append("media", filedata.fileAsBase64); //passing document as base64 string .Also tried passing it as Buffer, UnitArray and PDFDocument

let headers = formData.getHeaders();

const config = {

headers: headers

}

var that = this;

const docresponse = await axiosCf({

method: "post",

url: folderCreateURL,

headers: config.headers,

data: formData

}).then(async (result) => {

console.log('Attachment uploaded successfully');

that.docresponse = result.data.succinctProperties["cmis:objectId"];

}).catch(error => {

console.log("Attachement upload failed - " + error);

that.docresponse = "";

});

}

However, when we test it using postman client which is passing the document as FileObject, it worksPostmanScreenshot -

Does anyone with any idea on how to resolve this issue?

BTP DMS Rest API link used for creating document for reference - https://api.sap.com/api/CreateDocumentApi/path/post_browser__repository_id__root__directory_path_

Regards,Jigar Salecha

divyeaggarwal
Explorer
0 Kudos
@jigar_salecha I am getting similar issue...Did you found any solution for this?
renuka23
Explorer
0 Kudos

@jigar_salechaI am getting similar issue...Did you find any solution for this?

rupesh1999
Discoverer
0 Kudos
Hi Jigar Salecha, I am also facing similar issue , Did you get chance to get this issue fixed , if yes could you please share the solution.

Accepted Solutions (0)

Answers (1)

Answers (1)

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Kudos
renuka23
Explorer
0 Kudos
This document is related to folder creation, but I want to upload the file to DMS using code where we are facing issues with file format