How to get sharepoint online (office 365) data in cloud/windows azure (provider) hosted app using Javascript?

How to get sharepoint online (office 365) data in cloud/windows azure (provider) hosted app using Javascript?
I wish to retrieve sharepoint online data in html page (hosted in windows azure) using javascript and then need to play with AngularJS

Hi,
According to your description, you might want to get data from Office 365 SharePoint Online(also known as host web) and pass to the Provider Hosted App which is hosted
in Windows Azure site.
I would suggest you take a look at the links below about accessing data from the host web
 for a quick start:
https://msdn.microsoft.com/en-us/library/office/fp179927(v=office.15).aspx#SP15Accessdatafromremoteapp_Codeexample
http://dannyjessee.com/blog/index.php/2014/07/accessing-sharepoint-data-from-provider-hosted-apps-use-the-right-context/
Aother sample solution for your reference:
https://code.msdn.microsoft.com/SharePoint-2013-Get-the-0ec36bb6
Best regards
Patrick Liang
TechNet Community Support

Similar Messages

  • Retrieve data from a list in SharePoint 2013 provider hosted App using CSOM

    I have developed a provider hosted app in SharePoint 2013. As you already know, Visual Studio creates web application and SharePoint app. The web application gets hosted inside IIS and the SharePoint App in SharePoint site collection. I'm trying to get
    data from a list hosted in SharePoint using CSOM. But I get ran insecure content error. 
    here is my code in Default.aspx
        <script type="text/javascript" src="../Scripts/jquery-1.8.2.js"></script>
        <script type="text/javascript" src="../Scripts/MicrosoftAjax.js"></script>
        <script type="text/javascript" src="../Scripts/SP.Core.js"></script>
        <script type="text/javascript" src="../Scripts/INIT.JS"></script>
        <script type="text/javascript" src="../Scripts/SP.Runtime.js"></script>
        <script type="text/javascript" src="../Scripts/SP.js"></script>
        <script type="text/javascript" src="../Scripts/SP.RequestExecutor.js"></script>
        <script type="text/javascript" src="../Scripts/App.js"></script>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
            <title></title>
        </head>
        <body>
            <form id="form1" runat="server">
            <div>
                <input id="Button1" type="button" value="Get title via CSOM" onclick="execCSOMTitleRequest()" /> <br />
                <input id="Button2" type="button" value="Get Lists via CSOM" onclick="execCSOMListRequest()" />
            </div>
                <p ID="lblResultTitle"></p><br />
                <p ID="lblResultLists"></p>
            </form>
        </body>
        </html>
    and App.js is:
        var hostwebUrl;
        var appwebUrl;
        // Load the required SharePoint libraries
        $(document).ready(function () {
            //Get the URI decoded URLs.
            hostwebUrl =
                decodeURIComponent(
                    getQueryStringParameter("SPHostUrl")
            appwebUrl =
                decodeURIComponent(
                    getQueryStringParameter("SPAppWebUrl")
            // resources are in URLs in the form:
            // web_url/_layouts/15/resource
            var scriptbase = hostwebUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            //$.getScript(scriptbase + "/MicrosoftAjax.js",
            //   function () {
            //       $.getScript(scriptbase + "SP.Core.js",
            //           function () {
            //               $.getScript(scriptbase + "INIT.JS",
            //                   function () {
            //                       $.getScript(scriptbase + "SP.Runtime.js",
            //                           function () {
            //                               $.getScript(scriptbase + "SP.js",
            //                                   function () { $.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest); }
        function execCrossDomainRequest() {
            alert("scripts loaded");
        function getQueryStringParameter(paramToRetrieve) {
            var params = document.URL.split("?")[1].split("&");
            var strParams = "";
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve)
                    return singleParam[1];
        function execCSOMTitleRequest() {
            var context;
            var factory;
            var appContextSite;
            var collList;
            //Get the client context of the AppWebUrl
            context = new SP.ClientContext(appwebUrl);
            //Get the ProxyWebRequestExecutorFactory
            factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
            //Assign the factory to the client context.
            context.set_webRequestExecutorFactory(factory);
            //Get the app context of the Host Web using the client context of the Application.
            appContextSite = new SP.AppContextSite(context, hostwebUrl);
            //Get the Web
            this.web = context.get_web();
            //Load Web.
            context.load(this.web);
            context.executeQueryAsync(
                Function.createDelegate(this, successTitleHandlerCSOM),
                Function.createDelegate(this, errorTitleHandlerCSOM)
            //success Title
            function successTitleHandlerCSOM(data) {
                $('#lblResultTitle').html("<b>Via CSOM the title is:</b> " + this.web.get_title());
            //Error Title
            function errorTitleHandlerCSOM(data, errorCode, errorMessage) {
                $('#lblResultLists').html("Could not complete CSOM call: " + errorMessage);
        function execCSOMListRequest() {
            var context;
            var factory;
            var appContextSite;
            var collList;
            //Get the client context of the AppWebUrl
            context = new SP.ClientContext(appwebUrl);
            //Get the ProxyWebRequestExecutorFactory
            factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
            //Assign the factory to the client context.
            context.set_webRequestExecutorFactory(factory);
            //Get the app context of the Host Web using the client context of the Application.
            appContextSite = new SP.AppContextSite(context, hostwebUrl);
            //Get the Web
            this.web = context.get_web();
            // Get the Web lists.
            collList = this.web.get_lists();
            //Load Lists.
            context.load(collList);
            context.executeQueryAsync(
                Function.createDelegate(this, successListHandlerCSOM),
                Function.createDelegate(this, errorListHandlerCSOM)
            //Success Lists
            function successListHandlerCSOM() {
                var listEnumerator = collList.getEnumerator();
                $('#lblResultLists').html("<b>Via CSOM the lists are:</b><br/>");
                while (listEnumerator.moveNext()) {
                    var oList = listEnumerator.get_current();
                    $('#lblResultLists').append(oList.get_title() + " (" + oList.get_itemCount() + ")<br/>");
            //Error Lists
            function errorListHandlerCSOM(data, errorCode, errorMessage) {
                $('#lblResultLists').html("Could not complete CSOM Call: " + errorMessage);
    Any solution is appreciated.

    Hi,
    To retrieve data from list in your provider-hosted app using SharePoint Client Object Model(CSOM), you can follow the links below for a quick start:
    http://msdn.microsoft.com/en-us/library/office/fp142381(v=office.15).aspx
    http://blogs.msdn.com/b/steve_fox/archive/2013/02/22/building-your-first-provider-hosted-app-for-sharepoint-part-2.aspx
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to Get user profile properties in provider -cloud hosted app in sharepoint online - office 365 using REST API?

    How to Get user profile properties in provider -cloud hosted app in sharepoint online - office 365 using REST API?
    any idea?

    Hi,
    From your description, my understanding is that you want to get user profile properties in provider-hosted app in SharePoint online using REST API.
    Here is sample code for getting user profile properties:
    http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html
    Here is a blog below about accessing data from the provider-host apps:
    http://dannyjessee.com/blog/index.php/2014/07/accessing-sharepoint-data-from-provider-hosted-apps-use-the-right-context/
    Best Regards,
    Vincent Han
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to change Site Share mail template in SharePoint online (Office 365)

    Hi,
    I want to change the default mail template used in SharePoint Online (Office 365) which is as follows
    I want to change the logo of microsoft with my custom logo and message below that logo.
    How could i do that?

    in Office365 SharePoint Online, if you wan to customize the alert template you need to customize the Alerttemplates.xml under 14 folder on Online server, but it is not permitted, check this article you
    also have seen.
    You can also post this question related SharePoint Online in dedicated Office365 SharePoint Online forum, you can get a better assistance there,
    http://community.office365.com/en-us/forums/151/categories.aspx
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/0d31bb5d-d46b-425a-9f48-6100404b95d8/sharepoint-online-custom-alert-emails?forum=sharepointcustomizationprevious

  • How to install app using powershell in sharepoint online - office 365?

    How to install app using powershell in sharepoint online - office 365?

    Hi
    check this similar post
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/1f0cd45a-00e1-4452-bafe-83c6ee3a59db/can-i-deploy-a-sharepointapp-to-office-365-using-powershell?forum=appsforsharepoint
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Any way to get all users's user profile proeprty using CSOM c# for sharepoint online - office 365?

    Any way to get all users's user profile proeprty using CSOM c# for sharepoint online - office 365?

    Since CSOM provides methods for operations related to people per
    user scope, you could retrieve all site users first using SP.Web.siteUsers
    property. and then use SP.UserProfiles.PeopleManager.getUserProfilePropertyFor
    Method to get property.
    [custom.development]

  • Error while executing script for sharepoint online (office 365) - the remote server returned an error: (503) server unavailable

    error while executing script for sharepoint online (office 365) - the remote server returned an error: (503) server unavailable.
    I am creating many site collections reading records from sharepoint list using powershell in sharepoint online tenant (office 365).
    Few site collections are created and then getting above error so this error record will be skipped then few succeeding record processed then again getting error.
    pattern is like:
    success
    success
    success
    success
    Error
    success
    success
    success
    success
    success
    success
    error
    success

    Hi,
    As it is an online environment, to troubleshoot this issue in an easier way, I suggest you contact Office 365 Support to see if there is any useful information in
    the log files in the server side:
    https://support.office.com/en-us/article/Contact-Office-365-for-business-support-32a17ca7-6fa0-4870-8a8d-e25ba4ccfd4b?ui=en-US&rs=en-US&ad=US
    Best regards
    Patrick Liang
    TechNet Community Support

  • Is possible to site mailbox email address with different domains in sharepoint online - office 365

    Can I set site mailbox email address with different domains in sharepoint online - office 365?
    For eg I have two dns link with office 365 account - abc.com, xyz.com
    So can i set site mailbox email according  using powershell like follwoing
    New-SiteMailbox –DisplayName "test" -Name "[email protected]" –SharePointUrl $NewlyCreatedsiteurl
    New-SiteMailbox –DisplayName "test" -Name "[email protected]" –SharePointUrl $NewlyCreatedsiteurl

    Hi Biraj,
    From your description, you would like site mailbox to have two email address.
    Since the issue is related to SharePoint online and Exchange online, I'd recommend you contact online support engineer for sufficient resource and more assistance. For your convenience:
    http://community.office365.com/en-us/f/154.aspx
    In addition, I find some information that might be relevant for your reference:
    Quotes from
    https://support.office.com/en-sg/article/Prepare-for-using-site-mailboxes-in-Office-365-6381daa5-3d98-4629-972d-d19e1dc48c1b
    Can I rename a site mailbox?            
    The display name of a site mailbox is the SharePoint team site display name. If you change the display name of the site in SharePoint, the display name also changes in Outlook. However, the site email address won’t be changed.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Lotus notes migration to SharePoint online Office 365

    Hi there,
    My organization is looking to migrate from Lotus notes to SharePoint Online Office 365 (SharePoint 2013).
    We are doing this without any help of a tool.
    I am going to create the wiki pages.
    There are around 1600 pages which are interlinked and approximately 15 links on every page.
    Is there any means I can automate the linking of wiki pages.
    Can a workflow be written to do so..??
    Please advise
    Many thanks.

    Yes, this can be automated. However in doing so you're effectively building your own tool which will cost more than buying a pre-built one.
    This isn't going to be possible with a SharePoint workflow. First you'll have to read the Lotus notes content, then you'll want to serialise that into a format for import and clean up any links or dead pages. Then you'll have to use the CSOM or REST
    APIs to create, populate and publish those pages.
    This won't be a quick task.

  • Scan to Sharepoint Online (Office 365)

    I'm looking for a solution that allows me to scan a document and upload directly to Sharepoint online.
    We use CRM 2011 online and am going to integrate Sharepoint as part of Office 365 so that each account in CRM has a sharepoint folder. What I need to do is scan a document directly into this account folder quickly and easily.
    Can anyone please recommend a scanner that has the ability to do this out of the box, or perhaps a decent bit of software that would allow me to use our existing Dell 2335 MFP to do the same thing?
    The key thing we need is to minimise the number of steps required and the complexity of the process so that training required is minimal.
    Thanks

    KnowledgeLake is releasing Connect 5.0 that allows the user to scan and upload directly to Office 365.
    Connect 5.0 Coming Soon!
    Here at KnowledgeLake we’re extremely excited for the forthcoming Connect 5.0 release. This new
    release has a reengineered UI that’s jam packed with new and upgraded features for SharePoint 2010 and Office 365. I’m particularly excited for the O365 functionality and looking forward to posting a follow up to my
    Connect 4.6 0ffice 365 integration piece. Connect 5.0, in my humble opinion, will change the landscape of how users interact with SharePoint document assists and SharePoint overall.
    Look for my next how-to post on the Office 365 Integration.
    Read the full post
    here on our KnowledgeLake Team SharePoint Blog.
    Connect 5.0 & Office 365 – Scanning & Viewing Documents
    With the forthcoming release of Connect 5, KnowledgeLake gives the Office 365 end user more features and functionality for scanning and viewing. This new feature set is also available to SharePoint 2010 Enterprise users as well.
    Read the full post
    here on our KnowledgeLake Team SharePoint Blog.

  • How to get the current user name in Provider hosted app using appOnlyAccessToken

    Hi, 
    Please help me, how to get the HostWeb UserName in Provider Hosted App
    i have Provider hosted App, and Anonymous Authentication is enabled on AppWeb, using appOnlyAccessToken
    Below code does not return current user who Log in in hostweb, it is returning
    SharePoint App (app@sharepoint)
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;
    Below code gives a blank name when Anonymous Authentication is enabled, if Anonymous Authentication is disabled
    app prompts for credentials 
    HttpContext.Current.User.Identity.Name
    Thanks
    Ram

    Hi,
    Since you are using a provider Hosted app if you want to get the current logged in name than do not use AppOnlyAccessToken else use AccessToken which is App + user Context AccessToken.
    then 
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;will return proper user Name.
    HttpContext.Current.User.Identity.Name will never return the user as this object is related to IIS server of your App Server not sharepoint.you should set this as Anonymous in case of provider hosted app.you can download the below sample which uses the AccessToken which has user name in it.https://code.msdn.microsoft.com/Working-provider-hosted-8fdf2d95
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

  • Sharepoint provider hosted app using angularjs

    I am working on a provider hosted app and trying to access the list item through REST call using angularjs. But I am not able to access the list. Is it possible to access the sharepoint list through REST call using angularjs in a provider hosted app?
    Below is the code for angular:
    var hostWebApp = angular.module('HostWebList', []);
    Service:
    hostWebApp.service('$SharePointJSOMService', function ($q, $http) {
        this.getListItems = function ($scope, listTitle) {
            var deferred = $q.defer();
            //First we must call the EnsureSetup method
            JSRequest.EnsureSetup();
            var hostweburl = decodeURIComponent(JSRequest.QueryString["SPHostUrl"]);
            var appweburl = decodeURIComponent(JSRequest.QueryString["SPAppWebUrl"]);
            var restQueryUrl = hostweburl + "/_api/web/lists/getbytitle('ListName')/items";
            var executor = new SP.RequestExecutor(hostweburl);
            executor.executeAsync({
                url: restQueryUrl,
                method: "GET",
                headers: { "Accept": "application/json; odata=verbose" },
                success: function (data, textStatus, xhr) {
                    deferred.resolve(JSON.parse(data.body));
                error: function (xhr, textStatus, errorThrown) {
                    alert("request failed");
                    alert(textStatus);
    //getting -1003
                    alert(JSON.stringify(xhr));
    //{"responseAvailable":false,"body":,"Header":null}
                    deferred.reject(JSON.stringify(xhr));
            return deferred.promise;
    Controller:
    hostWebApp.controller('HostWebListController', function ($scope, $SharePointJSOMService) {
        $scope.listItem = null;
        var listName = "IncomingEmail";
        var promise = $SharePointJSOMService.getListItems($scope, listName);
        promise.then(function (data) {
            $scope.listItem = data.d.results;
            alert($scope.listItem);
            console.log("came inside the promise success method");
        }, function (data) {
            console.log("Error " + data);
    Following javascript files I have included:
     <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
      <script type="text/javascript" src="/_layouts/15/sp.js"></script>
     <script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>
     <script type="text/javascript" src="/_layouts/15/init.debug.js"></script>
    angular.js included. 
    I don't know what is the problem. Can anybody walk me through the problem. will be great help.

    Your REST request must be authenticated. So you must send the access token in the authorization header along with your request. The following link explains how you can get the access token when you using a provider hosted app.
    http://blog.mastykarz.nl/using-sharepoint-rest-api-in-provider-hosted-apps/
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • Template reference not getting reflected after Creating WSP file of SubSite in SharePoint Online ( Office 365)

    Hi all,
    I am following below Steps:
    Going to Library Setting.
    After Click on Some Custom Content Types in content Type section.
    Click on
    Document
    Set settings in Settings.
    Brows and Upload Document Template in “Default Content” Section.
    Click OK.
    After Uploading Default Template I want these uploade template in my newly created Sub site  (After saving Site as Template) which is created with wsp.
    When i  create new subsite i am not getting Default Content which have brwsed and Uploaded in Contenten Types.
    Please Give some idea regarding below Screen Shot.
    Thanks In Advance. Your help will be heighly appreciable.
    For example i have given Document Link from any Library/List but not getting that link in new subsite which was created  with wsp.
    Thanks In Advance. Your help will be heighly appreciable.
    Thanks,
    Vivek Pandey

    Hi Christoph,
    From the article you mentioned, it needs add JPG file type to Search Service Application, which was not supported for SharePoint online.
    I tried to add Picture content type to normal document library and tested the issue, it still displayed as item in Search results.
    However, if I created a Picture Library and add Document content type to it, both image and document can be previewed in search result.
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Connecting Exchange On-Premise to SharePoint Online (Office 365)

    Hi,
    Help, please.
    I’m running MS Exchange 2010 SP3 On-Premise and now I’m planning to deploy SP2013 in Office 365.
    How can I connect both? What are my options?
    Thanks in advanced.

    Users can connect to SharePoint calendars has no tie to Exchange. Your users will not be able to receive notifications from tasks, workflows, and so on. You will need to have Exchange Online and either set up hybrid Exchange (where you route mail
    that cannot be delivered online to your on-prem implementation), or move users into Exchange Online.
    Trevor Seward
    Follow or contact me at...
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
    Thank you very much Trevor. Now I have a starting point …..

  • Deleting old survey responses from Sharepoint Online (Office 365)

    We have an Office 365 implementation and are utilizing the hosted SharePoint to collect survey responses using the default survey app.  We continually collect survey responses, but only want to have up to date information.  Is it possible to automatically
    delete survey responses older than a specified number of days?
    Not sure if this is the right place, but Microsoft Support recommended posting here from the Office 365 Forums:
    http://community.office365.com/en-us/f/154/p/298352/909303.aspx#909303
    Thanks,
    Emplo

    Hi
    schedule a task on a local server a powershell scom script which will do the task
    An example hot to use it to connect to sharepoint online
    http://www.hartsteve.com/2013/06/sharepoint-online-powershell/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

Maybe you are looking for