Help creating a connector for sharepoint

Hello,

I'm trying to upload a file uploaded from a form with the upload widget to my sharepoint address.

I'm using a rest-post connector to recover the access token, and another one to attempt the upload.

The post url:  "mySiteAddress/_api/web/GetFolderByServerRelativeUrl('targetFolder')/Files/add(url='"+filename+"',overwrite=true)"

I'm sending 2 headers, Authorization, the access token, and Content-Type, myFile.getContentMimeType()

So far the connector works but the issue is that the uploaded file is corrupted, its contents are a plain text instead of its proper content.

The payload:

Document docu = apiAccessor.getProcessAPI().getDocument(myFile.getId())
DocumentValue result = new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(docu.getContentStorageId()), docu.getContentMimeType(), docu.getContentFileName())

 byte[] bytes = result.content;
 String s = new String(bytes, StandardCharsets.UTF_8);
 return s;

The connector is intended to upload any image format and PDF files.

 

Thanks for the assistance.