SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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(
    for (var i = 0; i < byteArray.byteLength; i++) {
        fileData += String.fromCharCode(byteArray[i])

    // once we have the file perform the actual upload
    PerformUpload(, 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?

share|improve this question
What is your POST message attempting to do, create a list or add a list item? What's stored in the fileData variable? – Rob Windsor Sep 1 '13 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 – o365spo Sep 2 '13 at 20:53
up vote 2 down vote accepted

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

share|improve this answer
It's working.. what I can't do is access sharePoint lists on other sites on our Domain. – o365spo Sep 2 '13 at 21:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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