-
Notifications
You must be signed in to change notification settings - Fork 117
/
basic-rest-cors.yaml
66 lines (59 loc) · 2.08 KB
/
basic-rest-cors.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
order: 5
id: outlook-tokens-and-service-calls-basic-rest-cors
name: Get a message using REST
description: Gets a message using REST without any back-end code.
host: OUTLOOK
api_set:
Mailbox: '1.5'
script:
content: |
$("#run").on("click", run);
function run() {
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result) {
const ewsId = Office.context.mailbox.item.itemId;
const token = result.value;
const restId = Office.context.mailbox.convertToRestId(ewsId, Office.MailboxEnums.RestVersion.v2_0);
const getMessageUrl = Office.context.mailbox.restUrl + '/v2.0/me/messages/' + restId;
const xhr = new XMLHttpRequest();
xhr.open('GET', getMessageUrl);
xhr.setRequestHeader("Authorization", "Bearer " + token);
xhr.onload = function (e) {
console.log(this.response);
}
xhr.send();
});
}
language: typescript
template:
content: |
<section class="ms-font-m">
<p>This sample shows how to get a message using REST, without any back-end code.</p>
</section>
<section class="samples ms-font-m">
<h3>Try it out</h3>
<button id="run" class="ms-Button">
<div class="ms-Button-label">Run</div>
</button>
</section>
language: html
style:
content: |
section.samples {
margin-top: 20px;
}
section.samples .ms-Button, section.setup .ms-Button {
display: block;
margin-bottom: 5px;
margin-left: 20px;
min-width: 80px;
}
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css
core-js@2.4.1/client/core.min.js
@types/core-js
jquery@3.1.1
@types/jquery@3.3.1