(I know there is a parameter for detailed, please read) Is there another call to make for detailed instead of simple? In Python I would just add '"view" : "Detailed"' in my params and the output would let me parse through all of the detailed output. However, when adding the detailed param in C# the SDK doesn't have the detailed keys so it throws errors when trying to parse through them.
var handleIDs =await rc.Restapi().Account("~").Extension(ext.id.ToString()).AnsweringRule().List(listAnsweringRulesParameters);
var fwdId = handleIDs.records[0].forwarding.rules[0].forwardingNumbers[0].id;
var fwdType = handleIDs.records[0].forwarding.rules[0].forwardingNumbers[0].type;
The SDK doesn't have a "forwarding" key (in fwdId and fwdType) after "records[0]" so it throws me an error, even though I'm requesting a detailed list
Trying to use the ID/Type to set the users default answering rule, if there's a more simplistic way of doing it please let me know
Best answer by PhongVu
I think the SDK has an issue to parse the response for the "Detailed" view. I will ask the SDK team to fix that. Meanwhile, you can work around the problem with this code:
public class DetailedAnsweringRuleInfo
{
public string uri { get; set; }
public string id { get; set; }
public string type { get; set; }
public string name { get; set; }
public bool? enabled { get; set; }
public ScheduleInfo schedule { get; set; }
public CalledNumberInfo[] calledNumbers { get; set; }
public CallersInfo[] callers { get; set; }
public string callHandlingAction { get; set; }
public ForwardingInfo forwarding { get; set; }
public UnconditionalForwardingInfo unconditionalForwarding { get; set; }
public QueueInfo queue { get; set; }
public TransferredExtensionInfo transfer { get; set; }
public VoicemailInfo voicemail { get; set; }
public GreetingInfo[] greetings { get; set; }
public string screening { get; set; }
public SharedLinesInfo sharedLines { get; set; }
public MissedCallInfo missedCall { get; set; }
};
public class CustomUserAnsweringRuleList
{
public string uri { get; set; }
public DetailedAnsweringRuleInfo[] records { get; set; }
public UserAnsweringRuleListPaging paging { get; set; }
public UserAnsweringRuleListNavigation navigation { get; set; }
};
static private async Task list_users_answering_rule_raw()
{
ListAnsweringRulesParameters listAnsweringRulesParams = new ListAnsweringRulesParameters{
view = "Detailed";
enabledOnly = false;
};
string endpoint = "restapi/v1.0/account/~/extension/~/answering-rule";
var response = await rcsdk.Get(endpoint, listAnsweringRulesParams);
var body = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<CustomUserAnsweringRuleList>(body);
foreach (var record in result.records)
{
dynamic jsonStr = JsonConvert.SerializeObject(record);
Console.WriteLine("=======");
Console.WriteLine(jsonStr);
}
}
I think the SDK has an issue to parse the response for the "Detailed" view. I will ask the SDK team to fix that. Meanwhile, you can work around the problem with this code:
public class DetailedAnsweringRuleInfo
{
public string uri { get; set; }
public string id { get; set; }
public string type { get; set; }
public string name { get; set; }
public bool? enabled { get; set; }
public ScheduleInfo schedule { get; set; }
public CalledNumberInfo[] calledNumbers { get; set; }
public CallersInfo[] callers { get; set; }
public string callHandlingAction { get; set; }
public ForwardingInfo forwarding { get; set; }
public UnconditionalForwardingInfo unconditionalForwarding { get; set; }
public QueueInfo queue { get; set; }
public TransferredExtensionInfo transfer { get; set; }
public VoicemailInfo voicemail { get; set; }
public GreetingInfo[] greetings { get; set; }
public string screening { get; set; }
public SharedLinesInfo sharedLines { get; set; }
public MissedCallInfo missedCall { get; set; }
};
public class CustomUserAnsweringRuleList
{
public string uri { get; set; }
public DetailedAnsweringRuleInfo[] records { get; set; }
public UserAnsweringRuleListPaging paging { get; set; }
public UserAnsweringRuleListNavigation navigation { get; set; }
};
static private async Task list_users_answering_rule_raw()
{
ListAnsweringRulesParameters listAnsweringRulesParams = new ListAnsweringRulesParameters{
view = "Detailed";
enabledOnly = false;
};
string endpoint = "restapi/v1.0/account/~/extension/~/answering-rule";
var response = await rcsdk.Get(endpoint, listAnsweringRulesParams);
var body = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<CustomUserAnsweringRuleList>(body);
foreach (var record in result.records)
{
dynamic jsonStr = JsonConvert.SerializeObject(record);
Console.WriteLine("=======");
Console.WriteLine(jsonStr);
}
}