I intend to end a zoom meeting via its api, I am trying to call the api but it gives me the error:
Error: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>300Unsupported Content Type
I am working on flask . I have written two functions for end meeting anticipating what type of response api wants but both give same error;
def end_meeting(meeting_id, auth_token):
url = f"https://api.zoom.us/v2/meetings/{meeting_id}/status"
headers = {
‘Authorization’: f"Bearer {auth_token}",
‘Content-Type’: ‘application/x-www-form-urlencoded’ # Adjusting content type to form data
}
data = {
‘action’: ‘end’
}
response = requests.put(url, headers=headers, data=data) # Send form data
if response.status_code == 204:
return f"Meeting {meeting_id} has been successfully ended."
else:
return f"Failed to end meeting {meeting_id}. Error: {response.text}"
i changed it to this:
def end_meeting(meeting_id, auth_token):
url = f"https://api.zoom.us/v2/meetings/{meeting_id}/status"
headers = {
‘Authorization’: f"Bearer {auth_token}",
‘Content-Type’: ‘application/json’
}
data = {
‘action’: ‘end’
}
response = requests.put(url, headers=headers, json=data)
if response.status_code == 204:
return f"Meeting {meeting_id} has been successfully ended."
else:
return f"Failed to end meeting {meeting_id}. Error: {response.text}"
and javascript tot his:
document.getElementById(“End-Button”).addEventListener(“click”, function() {
var meetingId = document.getElementById(“instant-ID”).value; // Retrieve the meeting ID
// Check if meeting ID is not empty before proceeding
if (meetingId.trim() === '') {
console.log("Meeting ID is empty");
return; // Prevent sending an empty meeting ID
}
// Data to be sent in the request
var data = { meeting_id: meetingId };
// AJAX request to the Flask route to end the meeting
fetch('/meetings/end_meeting_route', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data) // Sending meeting_id as JSON data
})
.then(response => response.text())
.then(result => {
console.log(result); // Log the result from the Flask route
// You can perform further actions based on the result if needed
})
.catch(error => {
console.error('Error:', error);
});