Sharepoint - SharePoint 2013 Call the REST API from SharePoint hosted app

Does your App request read permissions to User Profiles?

enter image description here


Set the Permissions on User Profiles = Read as mentioned in Rob's Answer and then the following code should work. We don't need to use request executor as we are not making a cross domain call here.

$.ajax({

    url:"http://<app web url>/_api/SP.UserProfiles.PeopleManager/GetMyProperties",
    headers:{ Accept:"application/json;odata=verbose" },
    success:function(data){
      alert(data.d.DisplayName);
    },
    error:function(jQxhr,errorCode,errorThrown){
      alert(errorThrown);
    }
});

Tags:

Rest