Hello Guys,
when I call star recording via API it return 409 error.
my code is below
function createSession(sessionId) { // See https://docs.openvidu.io/en/stable/reference-docs/REST-API/#post-openviduapisessions
return new Promise((resolve, reject) => {
$.ajax({
type: “POST”,
url: OPENVIDU_SERVER_URL + “/openvidu/api/sessions”,
data: JSON.stringify({
customSessionId: sessionId,
mediaMode: “ROUTED”,
recordingMode: “MANUAL”,
defaultOutputMode: “COMPOSED”,
defaultRecordingLayout: “BEST_FIT”,
defaultCustomLayout: “CUSTOM_LAYOUT”,
}),
headers: {
“Authorization”: “Basic " + btoa(“OPENVIDUAPP:” + OPENVIDU_SERVER_SECRET),
“Content-Type”: “application/json”
},
success: response => resolve(response.id),
error: (error) => {
if (error.status === 409) {
resolve(sessionId);
} else {
console.warn('No connection to OpenVidu Server. This may be a certificate error at ’ + OPENVIDU_SERVER_URL);
if (window.confirm(‘No connection to OpenVidu Server. This may be a certificate error at "’ + OPENVIDU_SERVER_URL + '”\n\nClick OK to navigate and accept it. ’ +
‘If no certificate warning is shown, then check that your OpenVidu Server is up and running at "’ + OPENVIDU_SERVER_URL + ‘"’)) {
location.assign(OPENVIDU_SERVER_URL + ‘/accept-certificate’);
}
}
}
});
});
}
// Call method
return new Promise((resolve, reject) => {
$.ajax({
type: “POST”,
url: OPENVIDU_SERVER_URL + “/openvidu/api/recordings/start”,
data: JSON.stringify({
“session”:mySessionId,
“name”:“MyRecording2”,
“outputMode”:“INDIVIDUAL”,
“hasAudio”: true,
“hasVideo”: true,
“recordingLayout”:“CUSTOM”,
“customLayout”:"",
“resolution”: “300x300”
}),
headers: {
“Authorization”: “Basic " + btoa(“OPENVIDUAPP:” + OPENVIDU_SERVER_SECRET),
“Content-Type”: “application/json”
},
success: response => resolve(response.id),
error: (error) => {
console.log(‘error.status’,error.status);
if (error.status === 409) {
resolve(mySessionId);
} else {
console.warn('No connection to OpenVidu Server. This may be a certificate error at ’ + OPENVIDU_SERVER_URL);
if (window.confirm(‘No connection to OpenVidu Server. This may be a certificate error at "’ + OPENVIDU_SERVER_URL + '”\n\nClick OK to navigate and accept it. ’ +
‘If no certificate warning is shown, then check that your OpenVidu Server is up and running at "’ + OPENVIDU_SERVER_URL + ‘"’)) {
location.assign(OPENVIDU_SERVER_URL + ‘/accept-certificate’);
}
}
}
});
});
Please help me to solve this issue.
OPENVIDU_RECORDING=true in .env file
Response