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

Similar Messages

  • How to debug sharepoint 2013 provider hosted app?

    We developed SharePoint 2013 provider hosted app using MVC 5 Entity Framework of Database first and publish in Windows Azure site as well as deployed that project to our SharePoint app Catalog. We need to change Windows azure site so we
    changed to publish in  another Windows Azure site and deployed again to our SharePoint app Catalog. No problem the app is working after we changed Windows Azure site. I am new of this technology I faced so hard of changed
    existing Windows Azure site to New Windows Azure site. Please tell me how to debug the SharePoint Provider hosted app? Please tell me step by step process.
     Thanks in Advance.

    Hi,
    According to your description, you might want to know how to debug provider hosted app.
    To get a quick start, I would suggest you take a look at the link below about
    Debugging SharePoint Apps That Are Hosted In Windows Azure Web Sites:
    http://blogs.technet.com/b/speschka/archive/2013/11/25/debugging-sharepoint-apps-that-are-hosted-in-windows-azure-web-sites.aspx
    Another two similar articles for your reference:
    http://sharepointfieldnotes.blogspot.jp/2013/03/making-it-easy-to-develop-and-debug.html
    http://blogs.msdn.com/b/officeapps/archive/2013/01/03/debugging-remote-event-receivers-with-visual-studio.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • SharePoint 2013 Provider hosted App installation error

    Hi All,
    I am trying to install a provider hosted app in SharePoint 2013. Installation goes for about 15mins and get "Sorry, something went wrong
    with adding the app. Click to retry."
    Please find belw ULS details for Correlation ID:
    Error when try to get access token when deploy AppInstanceId 7bcf1d9d-897a-48a1-b4f4-cd3120fd98a5 with AppPrincipalId i:0i.t|ms.sp.ext|[email protected]01b993b6. Exception=System.InvalidOperationException:
    An unexpected error was returned from the delegation service.  Error Code: 'invalid_client' Error Description: 'ACS65003: The clientId 'd12de581-316c-4224-b58b-e91ac2042150/www.SERVERNAME.DOMAIN.com@0d85160c-5899-44ca-acc8-db1501b993b6' is not a valid
    service identity.  Trace ID: 4a0c4974-94f4-4077-9a22-2ba5f0abb444  Correlation ID: 674d9839-686b-45f3-be46-31db4dc2a9d0  Timestamp: 2014-07-23 09:34:49Z'    
     at Microsoft.SharePoint.Administration.SPAzureAccessControlDelegationServiceClient.HandleUnexpectedError(SPAzureAccessControlDelegationServiceResponse delegationServiceResponse)    
     at Microsoft.SharePoint.ApplicationServices.SPApplicationContextAccessToken.GetResponseOrThrow[T](SPAzureAccessControlDelegationServiceClient delegationServiceClient, SPAzureAccessControlDelegationServiceResponse delegationServiceResponse)    
     at Microsoft.SharePoint.ApplicationServices.SPApplicationContextAccessToken.IssueApplicationContextAccessToken(SPServiceContext serviceContext, SPApplicationContextAccessTokenCreationParameters creationParameters)    
     at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForApplicationContext(SPIdentityContext userIdentityContext, String applicationId, Uri applicationRealm, SPApplicationContextAccessTokenType applicationTokenType, SPApplicationDelegationConsentType
    consentValue)    
     at Microsoft.SharePoint.SPServerToAppServerAccessTokenManager.GetAccessTokenForDeploymentTask(Guid siteId, SPUserToken userToken, String appPrincipalId)    
     at Microsoft.SharePoint.Lifecycle.SPAppPrincipalAccessTokenTask.<>c__DisplayClass1.<Deploy>b__0()
    sudesh withanage

    Hi  sudesh,
    According to your description, my understanding is that you encountered the error “An unexpected error was returned from the delegation service" when you try to add a SharePoint 2013 Provider hosted App.
    As the error message says, the clientId 'd12de581-316c-4224-b58b-e91ac2042150/www.SERVERNAME.DOMAIN.com@0d85160c-5899-44ca-acc8-db1501b993b6' is not a valid service identity when your SharePoint  try
    to get access token via ACS. Is there any plans to develop a low trust mechanism for non-connected scenarios? i.e. low trust provider hosted apps with no external connection, like say for a Bank who lock down external access.  Please  follow the
    steps as the blog  to set development environment for  SharePoint Low-Trust Apps:
    http://blogs.msdn.com/b/besidethepoint/archive/2012/12/10/sharepoint-low-trust-apps-for-on-premises-deployments.aspx?PageIndex=1#comments
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Report Viewer control in sharepoint 2013 provider hosted app

    sharepointSite/_vti_bin/ReportServer
    We are migrating sp 2010 site to SP 2013 provider hosted app. we are using Report viewer control (version 10.0.0) in .net application app server, And the reporting service is configured in sharepoint site and report is uploaded in the document
    library. We are using claims based authentication
    ReportViewer1.ServerReport.ReportServerUrl =
    newUri("sharepointSite/_vti_bin/ReportServer");
    ReportViewer1.ServerReport.ReportPath = @"sharepointSite/_vti_bin/ReportServer?sharepointSite/Reports/Report1.rdl";
    and am getting an error
    ReportServerException: For more information about this error navigate to the report server on the local server machine, or enable remote errors]
    [ReportServerException: The user does not exist or is not unique.]
    [ReportServerException: Report Server has encountered a SharePoint error. (rsSharePointError)]
       Microsoft.Reporting.WebForms.ServerReportSoapProxy.OnSoapException(SoapException e) +82
       Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.ProxyMethodInvocation.Execute(RSExecutionConnection connection, ProxyMethod`1 initialMethod,
    ProxyMethod`1 retryMethod) +770
       Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession() +105
       Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 parameters) +163
       BP.SDC.eXPP.UIAppsWeb.UserControls.Baseline.ProgressDashboard.RefreshDashboardReport(Int32 userRoadMapDisciplineId, String roadmapSection)
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
    Can you please help me to solve this issue

    Hi,
    According to your post, my understanding is that you had issues about the provider hosted app.
    Per the error, the issue may be related to the permission issue.
    For a better troubleshooting, we can check with the following steps.
    To norrow down the issue, please create a new and clean app to test whether it has the same issue.
    You can check the ULS log to see if anything unexpected occurred when you deploy the app and open the site page.
    For SharePoint 2013, by default, ULS log is at
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    You can check the ULS log by the methods here:
    http://blogs.msdn.com/b/opal/archive/2009/12/22/uls-viewer-for-sharepoint-2010-troubleshooting.aspx
    http://msdn.microsoft.com/en-us/library/gg193966(v=office.14).aspx
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Getting Client Context in Class Library for Sharepoint 2013 provider hosted app

    I have created an MVC Provider hosted app.
    From my controllers I can easily get the client context via:
    var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
    But in my layout page, I have a call that gets the topnavbar and replicates it:
    @foreach (var nav in HostHelper.GetNav(this))
    <li class='static'>
    <a class='static menu-item ms-core-listMenu-item ms-displayInline ms-navedit-linkNode' href='@nav.Url'>
    <span class='addition-background ms-navedit flyoutArrow'>
                                                            <span class='menu-item-text'>
    @nav.Title                                                
    </span>                                                   </span>                                               
    </a>                                           
    </li>                                       
    This causes an error because I am not sure how to get the clientcontext from my class. I have tried:
    public static NavigationNodeCollection GetNav()       
    var spContext = SharePointContextProvider.Current.GetSharePointContext(System.Web.HttpContext.Current);
    using (var clientContext = spContext.CreateUserClientContextForSPHost())
    if (clientContext != null)
    NavigationNodeCollection topNav = clientContext.Web.Navigation.TopNavigationBar;            
    clientContext.Load(topNav);                   
    clientContext.ExecuteQuery();                   
    return topNav;                                       }           
    return null;       
    put it doesnt get the client context

    Hi,
    According to your description,  my understanding is that you want to get SharePoint provider hosted app ClientContext in the layout page.
    In the layout page, it needs to use TokenHelper Class to get access token and then retrieve the ClientContext.
    Here is a detailed article for your reference:
    How to Get SharePoint Client Context in SharePoint Apps (Provider Hosted / SharePoint Access ) in CSOM (Client Side Object Model)
    Thanks
    Best Regards
    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]

  • SharePoint 2013 Provider-Hosted App Installs, throws File Exists error.

    I have a SP2013 Provider-hosted app with DevExpress controls that was working fine until just recently. I am getting the following error when I try to F5 DEBUG:
    "Error occurred in deployment step 'Install app for SharePoint': The file exists."
    The app actually installs and executes but the debugger detaches very quickly plus it is prompting with the nagging aforementioned message. There are no AppUninstall / AppInstall / AppUpgraded events being handled.
    Thanks in advance.

    I tried retraction, cleaning, reinstalling - nothing worked. I tried a new app in the site collection and a new app in a new site collection - still no luck. In the end the problem was more simple, but the "File exists" error was not helpful in determining
    the root cause. Perhaps others will hit this thread and find the solution helpful. Visual Studio will typically switch automatically to "Run as Administrator" mode whenever debugging a SP App for 2013. In my case, it wasn't. I had one or two existing Apps
    that never prompted me but ran fine and in this case, new apps weren't automatically running as the Administrator. After changing this behavior the app (and new apps) work as expected.

  • Cryptographic error on a SharePoint 2013 Provider Hosted App

    Below mentioned is the error:
    System.TypeInitializationException: The type initializer for 'ABABABA.TokenHelper' threw an exception. ---> System.Security.Cryptography.CryptographicException: Access denied. at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32
    hr) at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String
    fileName, Object password, X509KeyStorageFlags keyStorageFlags) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
    We are pretty sure the App Pool account has access to the file and the path is correct. We have had a dozen number of people who checked these things out.
    Please help out.
    Thanks,
    Aseem Sood

    Hi Aseem,
    Please check the App pool account password and re-enter it once again in advanced settings.
    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

  • How to set another instance of same live app as test app sharepoint 2013 provider hosted

    Hi
    I have SharePoint 2013 provider hosted app published in azure now i need to deploy another instance on same app as separate app for testing purposes, i have created another site in azure and done all profile adding packaging the app with visual studio to
    deploy .App file to SharePoint catalog.  problem is that .app file is same name and when i going to add,  it replace with same version witch deploy as live instance.
    Any one can give solution how to handle this greatly appreciated ...
    Kind Regards
    Radika

    Hi Radika,
    According to your description, there is already an app deployed in your site, you want to deploy another instance of it to the same site for testing purpose.
    As a common practice, when developing an app, for not overriding the previous version, it is recommended to create another project for testing used only with another
    name.
    By doing this, we can keep the development in the testing project, when it is done, migrate the newly customization to the original project and deploy it with a new
    version number.
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Patrick Liang
    TechNet Community Support

  • 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

  • Sharepoint online provider-hosted app AppEventReceiver callout failed.

    I've created an AppEventReceiver for sharepoint online provider-hosted app, I can deploy the app if i hosted the remote web application on MS Azure, it work fine. if hosted the remote web application on local machine IIS whith public ip address, when
    I deploy the app online the following error:
    The remote event receiver callout failed.
    Details: There was no endpoint listening at
    http://115.193.xxx.xxx:6666/AppEventReceiver.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
    two question:
    1. does the provider-hosted app, (remote web application  )must host on Azure so that the AppEventReceiver (appinstalled) then trigger?
    2. what need to do when host on local machine IIS whith public ip address?

    try these link:
    http://www.sharepointnutsandbolts.com/2013/07/deploying-sp2013-provider-hosted.html
    if you are using office365 for sharepoint then you can develope list using sandbox solution .

  • How to auto populate data from one list in SharePoint 2007 into another list based on a key value?

    Hi,
    As a part of new requirement in my project I am supposd to work on SharePoint 2007. I have one List (BCExtract - Main list) with all data related to an Application (like ID, name, app manager RTO etc).
    I have created another list which has form to be filled by a user (with details about his/her applications). My requirement is that when the user enters AIT ID then the page should refresh (probably after hitting enter) and other details like Application
    name, RTO etc which is present in another list gets auto populated depending on the AIT ID (unique column) entered so reduce the burden on the user.
    Please suggest me how this can be done. I do not have permission for obtaining SharePoint Designer and I do not know JQuery. Infopath is ok but if this can be done through SharePoint 2007 alone then it would be great.
    Thanks....

    Hello,
    You can either use jquery/jaavscript or infopath form to achieve this. There is no default way to do this.
    I would suggest jquery because you can put script in newform/editfor.aspx page using content editor webpart. Refer this link for jquery:
    To get value from list:
    http://social.technet.microsoft.com/Forums/en-US/ac47fe2a-ccb6-4f5b-b274-703aecc6cb0a/get-list-items-in-sharepoint-2010-by-using-jquery
    http://www.robertkuzma.com/2010/08/read-list-items-using-sharepoint-web-services-and-jquery/
    To set value in column:
    http://paulgalvinsoldblog.wordpress.com/2009/06/13/quick-and-easy-use-jquery-to-set-a-text-field%E2%80%99s-value-on-a-sharepoint-form/
    http://spservices.codeplex.com/discussions/468729
    If you use infopath form, then you need to create two data connection to get data from both lists. Later you can set value in fields based on selection using rule. This can be possible without code.
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to get data from subsites list of SharePoint 2010 in ssrs

    Hi,
    Can someone help me on this issue.
    I want to create a report using ssrs, I have some of the data in SQL and some of the data in sharepoint list.
    First I need to go to SQL and get the data from the table which contains URL for the subsite in sharepoint.
    after that I need to go to all the subsites and go to perticulat list in the subsites and get data from that list.
    for example, their is a top level site "abc"
    it contains sub site "123", "456","567", etc.. All this sub sites contain a list by name "Sample List", Now I need to go to that sub site list(Sample List) and get list-item column say "created By" which
    is created on particular date. 
    in my report, I need to print the sub site "url/Title" which comes from SQL database and list-item column  "Created By" of that sub site list "Sample List".
    I tried using subreport inside a report by using "Microsoft SharePoint List" as a datasource, but when it comes to real time we don't know how many subsites will be created, so we can't create a datasource for each subsite site.
    I guess we need to be using XML as a datasource, but how can we go to particular subsite in query while using XML, since all subsites have list with the same name ?
    I appreciate your help.
    Thank you,
    Kishore 

    Hi Kishore,
    SQL Server Reporting Services(SSRS) supports expression-based connection strings. This will help us to achieve the goal you mentioned in this case:
    Create a new report
    Create a Data Source in the report with the connection string like this:
    http://server/_vti_bin/lists.asmx (We use static connection string instead of expression-based connection string now, as it is not supported to get fields based on expression-based connection string in design time. We will change it to be expression-based
    connection string later)
    Create the data set(as you have done using XML query language). Please use list name instead of GUID in the listName parameter.
    Design the report(e.g. Add controls to the report)
    Now, let's change the connection string to be expression-based. First, please add a parameter to the report, move this parameter to top. This parameter is used to store the sub site name.
    Open the Data Source editor, set the connection string to be: ="http://server/" & Parameters!parameterCreatedInStep5.value & "_vti_bin/lists.asmx"
    In the main report, pass the sub site name to the report we created above via the parameter created in step5
    That is all.
    Anyway, this is actually a SQL Server Reporting Service(SSRS) question. You can get better support on this question from:
    http://social.technet.microsoft.com/Forums/en/sqlreportingservices/threads
    For more information about Expression-Based connection string, please see:
    http://msdn.microsoft.com/en-us/library/ms156450.aspx#Expressions
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jinchun Chen
    Jin Chen - MSFT

  • 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

  • SharePoint remote provider hosted apps - confusion around key questions

    For some time, I have been trying to get a provider hosted app setup to work, and I am afraid that I - as a relative novice - must have missed some key points despite hours of googling and reading. Here's my questions:
    A remote, provider hosted app, would have its AppWeb in a domain that is different from the host SharePoint Farm in which it is gets installed and used. In other words, the AppWeb may be located at remote.contoso-apps.com, where as the SharePoint farm uses
    for instance spslocal.mycorp.com. However, when you - in the SharePoint host farm - set up your App Domain/App isolation - you can only provide one value - which in this case would then need to be remote.contoso-apps.com??? Does that mean that each SharePoint
    Farm can only contain Apps from one vendor delivering remote apps? Or is the key in hard coding the app web in the manifest? (However, even if I've tried this it seems like the token SPAppWebUrl still translates into the pattern defined in the App Isolation
    Settings in the host farm???).
    Back to the AppWeb: Many bloggers have mentioned that you have to add some kind of SharePoint element to your App project (not the Web Project part) to get the AppWeb provisioned from Visual Studio 2013. But at what stage are these SharePoint elements actually
    provisioned - during some kind of publish operation of the Web Project part (the Pages, Scripts etc.) or when you install the app package (hardly the latter, since the first installation may be when a customer installs the app???). The reason I ask is (of
    course) that my SharePoint Elements do not seem to get provisioned. And just to test my very basic understanding: the AppWeb can be any pure IIS web site from the start - i.e., not a SharePoint Web App?
    Thanks for any help on these challenging issues!

    Paul,
    thanks for your effort, but unfortunately the answers do not get me much further.
    Question 1: You write "You can only use one domain, because cross-domain IFrame requests are blocked in SharePoint 2013". This is contrary to numerous other articles that explain how the SharePoint cross-domain library (SP.RequestExecutor.js) can be
    used to communicate across domains. From the outset, the whole idea about an AppWeb is - according to Microsoft documentation - that the AppWeb should be isolated from the HostWeb and therefore in a separate domain. 
    This article,
    http://msdn.microsoft.com/en-us/library/office/jj612823(v=office.15).aspx, even talks about scenarios where the SharePoint Host Web and App Web are in different security zones!
    So according to a load of other documentation it is indeeed a valid scenario I am addressing, but I still miss the key answers to the questions above. I suspect that the key is to hardcode certain URIs in your app that points to the cloud AppWeb
    (so the single App Domain specified in the Host Farm is not used at all), but I have failed to find the necessary documentation on this.
    Question 2: The article mentioned does not talk about the issues that I have asked about, specifically when the SharePoint elements in the App are created.
    Anyone with experience in this area? Thanks!

  • SharePoint Online - Provider hosted App - Deployed in on-premise environment

    Hi
    We are evaluating SharePoint online and wanted to know if the following is possible? If yes, can anyone share his/her experience and issues faced?
    We want to deploy a provider-hosted app to a on-premise environment. This app will need to connect to SharePoint online. What are the requirements from hosting perspective for the on-premise server? Does the server require anything specific so that it is
    able to connect to SPOnline? Should it be outside the corporate firewall?
    What is the difference between SharePoint online standard and dedicated plans, in the context of Provider hosted app. Are there limitations with respect to what can & cannot be done in a Provider hosted app in these environments?
    How do I know if am using a SharePoint online standard or a dedicated plan? Where to look for?
    I have seen few articles where the provider hosted app is deployed to windows azure and is connecting to SharePoint online. However this is not the case with us (i.e. we do not have windows azure for now)
    Regards,
    Deven

    Below links answer most of your questions:
    App- code
    http://msdn.microsoft.com/en-us/library/office/fp142381(v=office.15).aspx 
    How to create high trust apps-  http://msdn.microsoft.com/en-us/library/office/fp179901(v=office.15).aspx
    How to deploy- http://msdn.microsoft.com/en-us/library/office/jj860570(v=office.15).aspx
    Go to billing and subscriptions and you will see what plan you have. Dedicated plans names and options are in this link- http://technet.microsoft.com/en-us/library/dn151715.aspx 
    Regards
    Libin
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Mark As Answer Feel free to unmark answer if does not resolves your problem.

Maybe you are looking for

  • Best way to return an array of values from c++?

    I have a a group of structs made of a mix of primitive types in c++. I need to return these to Java but Im not sure the best way to return them quickly. Should I create a class corresponding to the structure in Java then create the class in C++ and s

  • WITH HOLDING TAX ON DOWN PAYMENT

    HI I am  using TCode F-47 for down payment request to be paid to vendor. In Vendor Master Record with holding tax information is activated. But at the time of processing payment against down payment request using TCode F-58 With holding tax not deduc

  • Installer with specific drivers

    Hello to everyone, I'm trying to build a installer for a measurement program I just wrote, wich only contians specific drivers for my hardware and LabVIEW runtime. My goal is to find a solution without installing the whole NI-DAQmx 9.6. The solution

  • ITS load balancing issue

    Hi all, During our testing we are getting a load balancing issue.  However, one of the agates in our network is has more CPU power than compared to the other agates in our ITS network.  The memory on all the agate servers is the same.  Our current is

  • How to Change the Windows Title in EP7.0

    Hi Can anyone provide some pointers on how to change the windows title bar in EP 6.0 We would like to remove the words "SAP Netweaver Portal" from the title. I have found OSS note  695903 however this refers to EP6.0 Thanks in advance. Ian