Why can't I call REST of the apps parent site from NAPA? I need data from a list on the same level as the app.

This chokes. And if I use the Apps URL, it can't find the list with GetByTitle.

function ProcessUpload(fileInput) {
var reader = new FileReader();
reader.onload = function (result) {
    var fileName = '',
     libraryName = '',
     fileData = '';

    var byteArray = new Uint8Array(result.target.result)
    for (var i = 0; i < byteArray.byteLength; i++) {
        fileData += String.fromCharCode(byteArray[i])

    // once we have the file perform the actual upload
    PerformUpload(fileInput.name, fileData);

reader.readAsArrayBuffer(fileInput);}function PerformUpload(fileName, fileData) {
var url;

var path = appWebUrl; var p = path.split('/');var approot = p[0]+"//"+p[2]+"/"+p[3]+"/"+p[4];

    url = approot +
      "@TargetSite='" + targetSiteUrl + "'" +
        "&@TargetLibrary='Documents'" +
        "&@TargetFileName='CV" + fileName + "'";

// use the request executor (cross domain library) to perform the upload
var reqExecutor = new SP.RequestExecutor(appWebUrl);
    url: url,
    method: "POST",
    headers: {
        "Accept": "application/json; odata=verbose",
        "X-RequestDigest": digest
    data: JSON.stringify({ '__metadata': { 'type': 'SP.List' }, 'Title': 'New title' }),

    contentType: "application/json;odata=verbose",
    binaryStringRequestBody: true,
    body: fileData,
    error: errorHandler


Might I be having a cross domain issue. Regardless I wonder I can consume list data from other site collections with REST/JSON?


  • What is your POST message attempting to do, create a list or add a list item? What's stored in the fileData variable? Commented Sep 1, 2013 at 19:10
  • it uploads a file to a sharePoint Document library. But it only lets me upload to the app host site. I will update the post to show the url
    – Hell.Bent
    Commented Sep 2, 2013 at 20:53

1 Answer 1


See this post on How to: Access SharePoint 2013 data from remote apps using the cross-domain library. The message you send needs to go to the App Web but in it you need to indicate that you want it to be executed on the Host Web. You do this using SP.AppContextSite.

For example, the URL to get the Title of the Host Web would be:

appweburl + "/_api/SP.AppContextSite(@target)/web/title?@target='" + hostweburl + "'",

If you're not familliar with the terms App Web and Host Web, see Host webs, app webs, and SharePoint components in SharePoint 2013

  • It's working.. what I can't do is access sharePoint lists on other sites on our Domain.
    – Hell.Bent
    Commented Sep 2, 2013 at 21:05

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.