I'm trying to get file binary data. I used below codes but it return null. In my application, user can select files from the library for download. I need to retrieve the binary file and then create zip file using jszip.js.
Any advise. Thanks.
var executor = new SP.RequestExecutor(appWebUrl);
var url = String.format("{0}/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('{1}/{2}/{3}')/$value?@target='{4}'",
appWebUrl, serverRelativeUrl, folderName, filename, hostWebUrl);
executor.executeAsync({
url: url,
method: "GET",
binaryStringResponseBody: true,
success: function (data) {
var result = data.body//this is null
},
error: function (err) {
$("#error").html(JSON.stringify(err))
}
});