on 2023 Jun 07 11:36 AM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
8 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.