OfficeDev/SharePoint-Add-in-JSOM-CrossDomain

Name: SharePoint-Add-in-JSOM-CrossDomain

Owner: Office Developer

Description: Use the SharePoint Cross Domain JavaScript library (CDL) to access SharePoint data from a remotely hosted web page without the need for OAuth tokens.

Created: 2015-08-12 20:15:58.0

Updated: 2018-01-11 03:58:15.0

Pushed: 2017-12-28 21:37:01.0

Homepage: null

Size: 26

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Access SharePoint data with the Cross Domain JavaScript Library

Summary

Use the SharePoint Cross Domain JavaScript library (CDL) to access SharePoint data from a remotely hosted web page without the need for OAuth tokens.

Applies to

Prerequisites

This sample requires the following:

Description of the code

The sample includes an instance of an Announcements list with two sample announcements in it. The list instance is deployed to the add-in web. When the start page loads, JavaScript in the CrossDomainExec.js file, in the remote domain, makes an AJAX call to SharePoint to get the announcements and displays them on the page.

The page looks similar to the following.

The add-in start page with a table showing the result of searching on the term "SharePoint".

Note: The start page of the add-in, CrossDomainCall.aspx, is a plain HTML file. It has an “aspx” extension because when a remote start page in a provider-hosted add-in is opened by SharePoint, SharePoint sends it a context token in the body of the HTTP request. To do this SharePoint must send a POST request. But the IIS Express that is hosting the remote page when you are debugging will not accept POST requests to a resource with a .html extension.

The sample demonstrates the following:

To use the sample
  1. Open Visual Studio as an administrator.
  2. Open the .sln file.
  3. In Solution Explorer, highlight the SharePoint add-in project and replace the Site URL property with the URL of your SharePoint developer site.
  4. Press F5.
  5. After the add-in installs, the consent page opens. Click Trust It.
  6. The page opens that the JavaScript runs immediately.
Troubleshooting

For troubleshooting steps, visit the “Troubleshooting the solution” table in the cross-domain library documentation article.

Questions and comments

We'd love to get your feedback on this sample. You can send your questions and suggestions to us in the Issues section of this repository.

Additional resources
Copyright

Copyright (c) Microsoft. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.