0

I wonder is it possible to add a file from a SharePoint hosted App to host web without setting Full permission for the Web?

function uploadFile(data) {            
var url = appUrl + "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('Style Library')/files/add(url='a.txt',overwrite=true)?@target='" + hostUrl + "'";
var executor = new SP.RequestExecutor(appUrl.toLowerCase());

executor.executeAsync(
    {
        url: url.toLowerCase(),
        method: "POST",
        body: data,
        headers: {
            "Accept": "application/json;odata=verbose",
        },
        success: function (result) {    
            console.log("success");
        },
        error: function (result, errorCode, errorMessage) {
            console.log(errorMessage);  
        }
    }
);}

When I run it with Manage permission on Web I get 403 Access Denied. When change to Full - 200 OK. Any ideas how to overcome it?

1 Answer 1

0

Instead of giving Full Control permissions on Web give Full Control permissions on the library only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.