// POST api/meeting // https://msdn.microsoft.com/en-us/skype/ucwa/scheduleanonlinemeeting public async Task <MeetingResponse> Post([FromBody] MeetingRequest mreq) { dynamic authDetails; try { authDetails = await AuthenticateUCWA(); } catch (Exception ex) { telemetry.TrackException(ex); throw CreateAPIError("3", "Could not authenticate to UCWA."); } try { MeetingRequestUCWA meeting = new MeetingRequestUCWA(); meeting.attendees = PreprocessAttendeeList(mreq.attendees); meeting.accessLevel = "Invited"; meeting.subject = mreq.subject; meeting.description = mreq.description; meeting.expirationTime = mreq.expirationTime; meeting.automaticLeaderAssignment = "SameEnterprise"; string json = JsonConvert.SerializeObject(meeting); HttpWebRequest req = CreateRequest(authDetails.onlineMeetingURL, "POST", authDetails.accessToken, "application/json", json); string res = GetResponse(req);////Creates the onlne meeting. dynamic jsonResponse = JsonConvert.DeserializeObject(res); MeetingResponse response = new MeetingResponse(); response.raw = jsonResponse; string baseUrl = WebConfigurationManager.AppSettings["WebPortalBaseUrl"]; UriBuilder uri = new UriBuilder(baseUrl); // Strip 'https://' part out of meeting join URL var joinUri = new Uri(jsonResponse.joinUrl.ToString()); var joinUrlComponents = joinUri.Host + joinUri.AbsolutePath; uri.Path = String.Format("/MeetingPortal/Join/Clinic/{0}", joinUrlComponents); response.clinicJoinUri = uri.ToString(); uri.Path = String.Format("/MeetingPortal/Join/Patient/{0}", joinUrlComponents); response.patientJoinUri = uri.ToString(); uri.Path = String.Format("/MeetingPortal/DeviceTest/{0}", joinUrlComponents); response.deviceTestUri = uri.ToString(); return(response); } catch (Exception ex) { telemetry.TrackException(ex); throw CreateAPIError("1", "Unexpected error occurred."); } }
// PUT api/meeting // https://msdn.microsoft.com/en-us/skype/ucwa/updateanonlinemeeting public async Task <dynamic> Put([FromBody] MeetingRequest mreq) { if (mreq.meetingId == null) { throw CreateAPIError("0", "Request is missing the required field 'meetingId'"); } dynamic authDetails; try { authDetails = await AuthenticateUCWA(); } catch (Exception ex) { telemetry.TrackException(ex); throw CreateAPIError("3", "Could not authenticate to UCWA."); } string meetingManagementURL = authDetails.onlineMeetingURL + "/" + mreq.meetingId; // Extract the magic etag value & GUID that need to be passed in PUT operations string guid = ""; string etag = ""; try { HttpWebRequest req = CreateRequest(meetingManagementURL, "GET", authDetails.accessToken); string res = GetResponse(req); dynamic jsonResponse = JsonConvert.DeserializeObject(res); etag = jsonResponse.etag.ToString(); foreach (var x in jsonResponse) { if (x.Value.ToString() == ucwaPassMeString) { guid = x.Name.ToString(); } } } catch (Exception ex) { telemetry.TrackException(ex); throw CreateAPIError("2", "Could not retrieve meeting information from UCWA"); } // Issue the PUT request based on passed values try { MeetingRequestUCWA meeting = new MeetingRequestUCWA(); meeting.attendees = PreprocessAttendeeList(mreq.attendees); meeting.accessLevel = "Invited"; meeting.automaticLeaderAssignment = "SameEnterprise"; meeting.subject = mreq.subject; meeting.description = mreq.description; meeting.expirationTime = mreq.expirationTime; JObject o = JObject.FromObject(meeting); o.Add("onlineMeetingId", mreq.meetingId); o.Add(guid, ucwaPassMeString); var json = o.ToString(); HttpWebRequest req = CreateRequest(meetingManagementURL, "PUT", authDetails.accessToken, "application/json"); req.Headers.Add("If-Match", '"' + etag + '"'); SendRequestBody(req, json); var res = GetResponse(req); return(JsonConvert.DeserializeObject(res)); } catch (Exception ex) { telemetry.TrackException(ex); throw CreateAPIError("1", "Unexpected error occurred."); } }