Hey everyone,
Having an issue with the below snippet, the error I'm getting is below as well. Have verified that fwdQueueExt.extensionNumber actually contains the extension it should go to, but still receive the below error. Also receiving the same error if I add the queue's extensionID/uri into fwdQueueExt.id/fwdQueueExt.uri, but don't think that matters because parameters.transfer doesn't take an ID/uri
Error:
System.NullReferenceException: Object reference not set to an instance of an object.
at MyAppName.Name.<RCAPICalls>d__4.MoveNext() in ServerNameScriptsAppNameRCTermUser.cs:line 430
Line 430 is:
parameters.transfer.extension = fwdQueueExt;
Code (removed personal info with x)
CallHandlingExtensionInfo fwdQueueExt = new CallHandlingExtensionInfo { };
if (callQueues.records.Count() > 0) { fwdQueueExt.extensionNumber = callQueues.records[0].extensionNumber.ToString(); }
else if (RINGCENTRAL_USERNAME == "+1xxxxxxxxx") { fwdQueueExt.extensionNumber = "xxxx"; }
else { fwdQueueExt.extensionNumber = "xxxx"; };
var parameters = new CreateAnsweringRuleRequest();
parameters.enabled = true;
parameters.type = "Custom";
parameters.name = "Forwarding Calls";
var schedule = new ScheduleInfo();
var weeklyRanges = new WeeklyScheduleInfo();
TimeInterval meetingTime = new TimeInterval();
meetingTime.from = "00:00";
meetingTime.to = "00:00";
weeklyRanges.monday = new TimeInterval[] { meetingTime };
weeklyRanges.tuesday = new TimeInterval[] { meetingTime };
weeklyRanges.wednesday = new TimeInterval[] { meetingTime };
weeklyRanges.thursday = new TimeInterval[] { meetingTime };
weeklyRanges.friday = new TimeInterval[] { meetingTime };
weeklyRanges.saturday = new TimeInterval[] { meetingTime };
weeklyRanges.sunday = new TimeInterval[] { meetingTime };
schedule.weeklyRanges = weeklyRanges;
parameters.schedule = schedule;
parameters.callHandlingAction = "TransferToExtension";
parameters.transfer.extension = fwdQueueExt;
var custRuleVar = await rc.Restapi("v1.0").Account("~").Extension(newDevID.extension.id.ToString()).AnsweringRule().Post(parameters);
Already have a script that re-assigns a terminated users extension to a temp user, but trying to make a custom rule to forward that temp users extension to the former users call queue.
Also tried going through some code samples, but no avail (that's where I got most of the above)