REST API Create Channels for PJSIP Extension

Anyone uses Asterisk 16 REST API Channels (POST) to create a call to an PJSIP extension with more than one contacts? When I call the POST, it doesn’t ring all devices assigned to one PJSIP extension. Any ideas why it’s doing this? Is it the device that’s causing it to choose priority over the other devices?

Please post the data that you are posting to Asterisk

Only a single channel can be dialed directly using ARI, if you want to dial multiple you have to use a Local channel to go to the dialplan which then uses PJSIP_DIAL_CONTACTS.

1 Like

string username = “freepbxuser”;
string password = “REST API Password”;
string encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding(“ISO-8859-1”).GetBytes(username + “:” + password));

            Channels channels = new Channels
                endpoint = string.Format("PJSIP/{0}", model.endpoint),
                extension = model.extension,
                context = "from-internal",
                priority = 1,
                timeout = 30,
                callerId = string.Format("Calling {0}", model.extension)

            var bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(channels));

            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://freepbx_ip:8089/ari/channels");
            webRequest.Headers.Add("Authorization", "Basic " + encoded);

            webRequest.Method = "POST";

            webRequest.Accept = "*/*";
            webRequest.ContentType = "application/json";
            webRequest.ContentLength = bytes.Length;

            using (var requestStream = webRequest.GetRequestStream())
                requestStream.Write(bytes, 0, bytes.Length);

            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

            string result;
            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                result = sr.ReadToEnd();

I found out the problem with my device that wasn’t ringing. It was the network settings on the device. It was using DNS for lookup and I changed it to use A Record. Now it’s working correctly. By the way, if you want to dial Zulu extensions, just place a “90” in front of the extension. Example: PJSIP/901001

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.