Hi, I am using @ringcentral/sdk in nextjs project and We have ringcentral widget from where we call people. Now, I want to transfer call to another number using API.
I am using this transfer API:
When call start I can get the telephonySessionId and partyId from this event:
window.addEventListener("message", (e) => {
const data = e.data;
switch (data.type) {
case "rc-active-call-notify":
On UI, I have created the transfer button and on click I execute transfer call button, in this function first I am getting the latest access_token:
var tokens = await platform.auth().data()
if(!tokens.access_token){
toast.error("You are not loggedIn with ringcentral.", {
duration: 2000,
});
return
}
const url = 'https://platform.ringcentral.com/restapi/oauth/token';
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
"Authorization": "BasicW344343"
};
const data = {
refresh_token: tokens.refresh_token,
grant_type: 'refresh_token',
client_id: '3343433se',
token: tokens.access_token
};
and then calling transfer call API:
const url = `https://platform.ringcentral.com/restapi/v1.0/account/867677/telephony/sessions/${telephonySessionId}/parties/${partyId}/transfer`;
const headers = {
'accept': 'application/json',
'content-type': 'application/json',
'Authorization': `Bearer ${tokenRes?.data?.access_token}`
};
What issue I am facing:
Sometimes, this transfer call is successful but sometimes not. I am getting these errors:
-- Token Not Found Error: This occurs when calling the refresh token API.
-- 404 Error on Transfer Call API: This sometimes happens during the call transfer.
these two errors, I am getting sometimes. But sometimes it works fine. What can be the issue?
Is it possible that the partyId or telephonySessionId is changing during the call? because I saved the details when call start and maybe that's why getting 404 for that?
Could you help me understand these issues and suggest how to resolve them?