diff --git a/README.md b/README.md index c3918b3..47fa344 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ https://developer.webex.com/docs/api/v1/meetings/update-a-meeting https://developer.webex.com/docs/api/v1/meetings/delete-a-meeting +See sample code in this repo under [./meetings/delete/](./meetings/delete/) + ## Language Reference ### Node diff --git a/meetings/README.md b/meetings/README.md index 1abee92..5161ea3 100644 --- a/meetings/README.md +++ b/meetings/README.md @@ -24,7 +24,9 @@ https://developer.webex.com/docs/api/v1/meetings/update-a-meeting ### DELETE -https://developer.webex.com/docs/api/v1/meetings/delete-a-meeting +Create a Webex meeting, using the REST API. + +See [./delete/README.md](./delete/README.md) ## Don't be a Stranger diff --git a/meetings/delete/README.md b/meetings/delete/README.md new file mode 100644 index 0000000..a8db2d9 --- /dev/null +++ b/meetings/delete/README.md @@ -0,0 +1,25 @@ +# Webex REST API Sample Code > Meetings > Delete + +This directory contains sample code demonstrating a JavaScript implementation of a REST client that calls the Meetings API to delete a meeting. + +## Get a Token + +See `Get a Token` in the main [/README.md](../../README.md) + +## Run the code + +This sample is JS, intended to be run via Node: + +`node ./delete_meeting.js` + +At the time of writing, we're using the latest LTS release of Node. + + +## Don't be a Stranger + +- https://developer.webex.com/docs +- https://developer.webex.com/blog +- https://developer.webex.com/support +- @WebexDevs: https://twitter.com/webexdevs + +Made with <3 by the Webex Developer Evangelism Team at Cisco diff --git a/meetings/delete/delete_meeting.js b/meetings/delete/delete_meeting.js new file mode 100644 index 0000000..4c68f88 --- /dev/null +++ b/meetings/delete/delete_meeting.js @@ -0,0 +1,74 @@ +/** + * _ + * __ _____| |__ _____ __ + * \ \ /\ / / _ \ '_ \ / _ \ \/ / + * \ 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 + + const myWebexDeveloperToken = 'REPLACE ME WITH YOUR WEBEX DEVELOPER PERSONAL ACCESS TOKEN'; + let 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 + */ + + +