├── .gitignore
├── LICENSE
├── README.md
├── SharePoint-Add-in-REST-OData-CrossDomain.sln
├── SharePoint-Add-in-REST-OData-CrossDomain
├── Announcements
│ ├── Elements.xml
│ └── SharePointProjectItem.spdata
├── AppIcon.png
├── AppManifest.xml
├── Features
│ └── Feature1
│ │ ├── Feature1.Template.xml
│ │ └── Feature1.feature
├── Package
│ ├── Package.Template.xml
│ └── Package.package
└── SharePoint-Add-in-REST-OData-CrossDomain.csproj
├── SharePoint-Add-in-REST-OData-CrossDomainWeb
├── Pages
│ └── CrossDomainCall.aspx
├── Properties
│ └── AssemblyInfo.cs
├── Scripts
│ ├── CrossDomainExec.js
│ └── _references.js
├── SharePoint-Add-in-REST-OData-CrossDomainWeb.csproj
├── Web.config
└── packages.config
└── description
└── image.png
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Office
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | page_type: sample
3 | products:
4 | - office-sp
5 | - office-365
6 | languages:
7 | - javascript
8 | extensions:
9 | contentType: samples
10 | technologies:
11 | - Add-ins
12 | - OAuth 2.0
13 | createdDate: 8/12/2015 3:31:39 PM
14 | ---
15 | # Access SharePoint data with the Cross Domain JavaScript Library and the REST\OData endpoints
16 |
17 | > SharePoint add-in model is considered as a legacy option for extending SharePoint user interface. Please see [SharePoint Framework documentation](https://aka.ms/spfx) and the [SharePoint Framework samples](https://aka.ms/spfx-webparts) for the future proven option to extend SharePoint Online. Possible backend services should be using Azure Active Directly based registration and related app models.
18 |
19 | ## Summary
20 | Use the SharePoint Cross Domain JavaScript library (CDL) and the SharePoint REST\OData endpoints to access SharePoint data from a remotely hosted web page without the need for OAuth tokens.
21 |
22 | ### Applies to ###
23 | - SharePoint Online and on-premise SharePoint 2013 and later
24 |
25 | ----------
26 | ## Prerequisites ##
27 | This sample requires the following:
28 |
29 |
30 | - A SharePoint 2013 (or later) development environment that is configured for add-in isolation. (A SharePoint Online Developer Site is automatically configured. For an on premise development environment, see [Set up an on-premises development environment for SharePoint Add-ins](https://msdn.microsoft.com/library/office/fp179923.aspx))
31 |
32 | - Visual Studio and the Office Developer Tools for Visual Studio installed on your developer computer
33 |
34 |
35 | ## Description of the code ##
36 | 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 a REST call to SharePoint to get the announcements and displays them on the page.
37 |
38 | The page looks similar to the following.
39 |
40 | 
41 |
42 | **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.
43 |
44 | The sample demonstrates the following:
45 |
46 |
47 | - How to use the key classes of the CDL to make calls from a remotely hosted domain to the SharePoint add-in web domain.
48 |
49 | - How to parse the JSON-formatted data returned from the SharePoint and how to display it dynamically.
50 |
51 |
52 |
53 | ## To use the sample #
54 |
55 | 12. Open **Visual Studio** as an administrator.
56 | 13. Open the .sln file.
57 | 13. In **Solution Explorer**, highlight the SharePoint add-in project and replace the **Site URL** property with the URL of your SharePoint developer site.
58 | 14. Press F5.
59 | 15. After the add-in installs, the consent page opens. Click **Trust It**.
60 | 16. The page opens that the JavaScript runs immediately.
61 |
62 |
63 | ## Troubleshooting
64 |
65 | For troubleshooting steps, visit the "Troubleshooting the solution" table in the [cross-domain library documentation article](http://msdn.microsoft.com/library/bc37ff5c-1285-40af-98ae-01286696242d).
66 |
67 | ## Questions and comments
68 |
69 | We'd love to get your feedback on this sample. You can send your questions and suggestions to us in the [Issues](https://github.com/OfficeDev/SharePoint_SP-hosted_Add-ins_Tutorials/issues) section of this repository.
70 |
71 |
72 | ## Additional resources
73 |
74 | - [SharePoint Add-ins](https://msdn.microsoft.com/library/office/fp179930.aspx )
75 | - [Creating SharePoint Add-ins that use the cross-domain library](https://msdn.microsoft.com/library/office/dn790708.aspx)
76 | - [Access SharePoint 2013 data from add-ins using the cross-domain library](https://msdn.microsoft.com/library/office/fp179927.aspx)
77 |
78 | ### Copyright ###
79 |
80 | Copyright (c) Microsoft. All rights reserved.
81 |
82 |
83 |
84 |
85 |
86 |
87 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
88 |
--------------------------------------------------------------------------------
/SharePoint-Add-in-REST-OData-CrossDomain.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.23107.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharePoint-Add-in-REST-OData-CrossDomain", "SharePoint-Add-in-REST-OData-CrossDomain\SharePoint-Add-in-REST-OData-CrossDomain.csproj", "{5A32A420-FE48-485C-B0D1-52D2FDC4D62E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharePoint-Add-in-REST-OData-CrossDomainWeb", "SharePoint-Add-in-REST-OData-CrossDomainWeb\SharePoint-Add-in-REST-OData-CrossDomainWeb.csproj", "{DB9AC460-7C70-4C51-8782-3E3757E31FDD}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {5A32A420-FE48-485C-B0D1-52D2FDC4D62E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {5A32A420-FE48-485C-B0D1-52D2FDC4D62E}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {5A32A420-FE48-485C-B0D1-52D2FDC4D62E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
19 | {5A32A420-FE48-485C-B0D1-52D2FDC4D62E}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {5A32A420-FE48-485C-B0D1-52D2FDC4D62E}.Release|Any CPU.Build.0 = Release|Any CPU
21 | {5A32A420-FE48-485C-B0D1-52D2FDC4D62E}.Release|Any CPU.Deploy.0 = Release|Any CPU
22 | {DB9AC460-7C70-4C51-8782-3E3757E31FDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {DB9AC460-7C70-4C51-8782-3E3757E31FDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {DB9AC460-7C70-4C51-8782-3E3757E31FDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {DB9AC460-7C70-4C51-8782-3E3757E31FDD}.Release|Any CPU.Build.0 = Release|Any CPU
26 | EndGlobalSection
27 | GlobalSection(SolutionProperties) = preSolution
28 | HideSolutionNode = FALSE
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/SharePoint-Add-in-REST-OData-CrossDomain/Announcements/Elements.xml:
--------------------------------------------------------------------------------
1 |
2 |