Within SPScriptlet 2 I’ll show how to use SharePoint 2013’s REST API to query common SPI properties. In the following example I’ve built a SharePoint App using Napa, first of all it’s important that your App has “Read” permissions on “Web” in order to ask for the web’s title. If you aren’t yet familiar with the concepts of App- and Host-Web, you should first dig into these topics on MSDN (http://msdn.microsoft.com/en-us/library/fp179925.aspx).

Consider your app has the following HTML

  <p id="message">Working on it ...</p>

I’m using SP.RequestExecutor, which handles all the cross domain action for me, in order to access the Host-Web from an App-Web. As you can see in figure 2, I’m specifying JSON as expected result for my REST call, SharePoint’s REST API is also able to return XML, but in the case of working with JavaScript, it’s more natural to deal data in JSON.

var getQueryStringParameter = function (parameterName){
  var params = document.location.search.split('?')[1].split('&');
  for(var i = 0; i < params.length; i++) {
    var keyValuePair = params[i].split('=');
    if(keyValuePair[0] === parameterName){
      return decodeURIComponent(keyValuePair[1]);

var getHostWebTitle = function(hostWebUrl){
  var appWebUrl = getQueryStringParameter('SPAppWebUrl');
  var executor = new SP.RequestExecutor(appWebUrl);
  var request = {
    url: appWebUrl + '/_api/SP.AppContextSite(@target)/web/[email protected]=\'' + hostWebUrl + '\'',
    method: 'GET',
    headers: {
      'Accept': 'application/json; odata=verbose'
    success: function(data) {
      var result = JSON.parse(data).d;
    error: function(data, errorCode, message){
      var errorMessage = '(' + erroCode + ') request error ' + message;
      console? console.log(errorMessage) : alert(errorMessage);

  var hostWebUrl = getQueryStringParameter('SPHostUrl');
  var scriptBase = hostWebUrl + `/_layouts/15/`;
  $.getScript(scriptBase + 'SP.RequestExecutor.js', function(){