-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdelete_meeting.js
73 lines (64 loc) · 2.84 KB
/
delete_meeting.js
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
67
68
69
70
71
72
73
/**
* _
* __ _____| |__ _____ __
* \ \ /\ / / _ \ '_ \ / _ \ \/ /
* \ V V / __/ |_) | __/> < @WebexDevs
* \_/\_/ \___|_.__/ \___/_/\_\
*
* DELETE a meeting in Webex with the REST API in Node
* https://developer.webex.com/docs/api/v1/meetings/delet-a-meeting
*
* Step 0: Have a (free) Webex account: https://cart.webex.com/sign-up
* Step 1: Log in to https://developer.webex.com/login
* Step 2: Find your bearer token at
* https://developer.webex.com/docs/getting-started under "Your
* Personal Access Token" in the middle of the page.
* Step 3: Replace the string on the line that defines const myWebexDeveloperToken,
* just below, with your personal bearer (access) token. Hit "save".
* Step 4: Replace the String on the line that defines let meetingId, just below,
* with the meeting ID that is a required unique identifier for the meeting
* being deleted.
* Step 5: Run this file with node from within
* this directory on the command line:
*
* node ./delete_meeting.js
*
* Step 6: Profit. Get your app listed in the Webex App Hub!
* https://apphub.webex.com/
*
*
*/
const https = require('https'); // https://nodejs.org/api/https.html
// You can set your WEBEXTOKEN env to your 12-hour token, OR...
const myWebexDeveloperToken = (typeof process.env.WEBEXTOKEN !=='undefined' )
? process.env.WEBEXTOKEN // Sets the token from your system's ENV if you've done that, OR...
: 'REPLACE ME WITH YOUR WEBEX DEVELOPER PERSONAL ACCESS TOKEN'; // ...replace this text with your 12-hour token
const meetingId = 'REPLACE WITH MEETING ID';
const options = {
method: 'DELETE', // https://en.wikipedia.org/wiki/Representational_state_transfer#Semantics_of_HTTP_methods
hostname: 'webexapis.com', // https://developer.webex.com/docs/basics
path: `/v1/meetings/${meetingId}`, // https://developer.webex.com/docs/meetings
port: 443, // https://en.wikipedia.org/wiki/HTTPS#Technical
headers: {
Authorization: `Bearer ${myWebexDeveloperToken}`, // https://oauth.net/2/bearer-tokens/
'Content-Type': 'application/json', // https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON
},
};
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`); // https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
res.on('error', (e) => {
console.error(`Error: ${e.message}`); // https://nodejs.org/api/errors.html#errormessage_1
});
});
req.on('error', (e) => {
console.error(e);
});
req.end();
/**
* Expected Output :
*
* The HTTPS request should receive a status code. We expect a 204 (No Content)
* status code if the action has been enacted and no further information is to be supplied.
*
* statusCode: 204
*/