cancel
Showing results for 
Search instead for 
Did you mean: 

Deployed SAP CAP application transforms POST data to string (to CMIS)

02-19-2022 10:49 AM
Erkan Explorer
931 views 0 comments
0 Likes
SAP Managed Tags
Subscribe

Hello all,

Im sending a post request from my SAPUI5 application to CAP backend and it is uploading file to CMIS repository (SAP Document Management System).

Everything was working normally till now but suddenly deployed version of app to Cloud Foundry is not accepting data as binary.

On local development (BAS) everything is working normally.

Here how I make the call from frontend

oEntry = { "fileBinary": fileBinary, //base64 string "};

$.ajax({ url: sURL, 
type: 'POST', 
async: false, 
processData:false, 
contentType: "application/json", 
data: JSON.stringify(oEntry), 
success: function (response) { ///// some stuff }, 
error: function (e) { ///// some stuff } }); 
  

serviceimpl.js - to upload file to CMIS

 let session = new cmis.CmisSession('https://api-sdm-di.cfapps.eu10.hana.ondemand.com/browser'); 
session.setToken(connJwtToken).loadRepositories() .then(() => session.createDocument(req.data.objectId, req.data.fileBinary, req.data.fileName)) .then(data => console.log(data)) 
  

In local development file is being sent and created correctly with following contents

test.txt

test

Once its deployed to CF and request is made, file has following contents

test.txt

dGVzdA==<br>

I feel like deployed version of HTML5 application is transforming/changing the POST call to accept only strings. Any help is appreciated, thank you.

Edit: Just updated the dependency of @sap/cds to newer version. It fixed my issue immediately.

0 Likes

Accepted Solutions (0)

Answers (0)