Dismiss Notice
We would like to remind you that we’re updating our login process for all 3CX forums whereby you will be able to login with the same credentials you use for the Partner or Customer Portal. Click here to read more.

Call Control API for v15.5

Discussion in 'CRM / Helpdesk / App Integration' started by ben.tggc, Nov 3, 2017.

Thread Status:
Not open for further replies.
  1. ben.tggc

    Oct 23, 2014
    Likes Received:

    I'm having an issue with the CreateExtension API call after moving to v15.5

    I can create extensions using this method but they are corrupt and can't be edited using the 3CX Management Console extension_editor page.

    After extension creation on the extension_editor page i notice that:
    • Forwarding Rules aren't set correctly
    • No Codecs are set (Can't see an option in the api for this)
    • Rights aren't set
    Here is my method i use to create an extension:

    public string newExtension(string email, string fName, string lName, string nextAvailableDn)
                    int ex = -1;
                    int.TryParse(nextAvailableDn, out ex);
                        Extension e = PhoneSystem.Root.GetTenant().CreateExtension(nextAvailableDn);
                        e.AuthID = nextAvailableDn;
                        var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                        var random = new Random();
                        var result = new string(
                            Enumerable.Repeat(chars, 7)
                                      .Select(s => s[random.Next(s.Length)])
                        e.AuthPassword = result;
                        var nums = "0123456789";
                        var result2 = new string(
                            Enumerable.Repeat(nums, 4)
                                      .Select(s => s[random.Next(s.Length)])
                        e.VMPIN = result2;
                        e.Enabled = true;
                        e.HidePresence = false;
                        e.Number = nextAvailableDn;
                        e.FirstName = fName;
                        e.LastName = lName;
                        e.EmailAddress = email;
                        Extension ex2 = PhoneSystem.Root.GetDNByNumber("102") as Extension;
                        e.BusyDetection = ex2.BusyDetection;
                        e.DeliverAudio = ex2.DeliverAudio;
                        e.Internal = ex2.Internal;
                        e.NoAnswerTimeout = ex2.NoAnswerTimeout;
                        e.OutboundCallerID = ex2.OutboundCallerID;
                        e.QueueStatus = ex2.QueueStatus;
                        e.RecordCalls = ex2.RecordCalls;
                        e.SupportReinvite = ex2.SupportReinvite;
                        e.SupportReplaces = ex2.SupportReplaces;
                        e.UserStatus = ex2.UserStatus;
                        e.VMEmailOptions = ex2.VMEmailOptions;
                        e.VMEnabled = ex2.VMEnabled;
                        e.VMPlayCallerID = ex2.VMPlayCallerID;
                        e.VMPlayMsgDateTime = ex2.VMPlayMsgDateTime;
                        e.EnableSRTP = ex2.EnableSRTP;
                        foreach (FwdProfile fp2 in ex2.FwdProfiles)
                            List<ExtensionRule> arrR = new List<ExtensionRule>();
                            foreach (ExtensionRule ExRule in fp2.ForwardingRules)
                                ExtensionRule er = e.CreateForwardingRule();
                                er.Conditions.Condition = ExRule.Conditions.Condition;
                                er.Conditions.Hours = ExRule.Conditions.Hours;
                                er.Conditions.CallType = ExRule.Conditions.CallType;
                                er.HoursRanges = ExRule.HoursRanges;
                                er.Data = ExRule.Data;
                                er.Forward.To = ExRule.Forward.To;
                                er.Forward.External = ExRule.Forward.External;
                            FwdProfile fp = e.CreateFwdProfile(fp2.Name);
                            fp.ForwardingRules = arrR.ToArray();
                        foreach (FwdProfile fps in e.FwdProfiles)
                            if(fps.Name == ex2.CurrentProfile.Name)
                                e.CurrentProfile = fps;
                            else if (fps.Name == ex2.OverrideProfile.Name)
                                e.OverrideProfile = fps;
                        foreach (var item in ex2.Groups)
                            Group g = PhoneSystem.Root.GetGroupByName(item.Name);
                            g.CreateGroupMember(e, "__DEFAULT__");
                catch (Exception ex)
                    nextAvailableDn = "Error: " + ex;
                return nextAvailableDn;
    As you can use from my code I have tried to copy many of my options from a preset extension.

    Any help or advise will be appreciated.
    LtFrankDrebin and Danny Lauwers like this.
Thread Status:
Not open for further replies.