News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Ring Out does not hang up using DELETE
Tags: ring out
Apr 7, 2016 at 12:27pm   •   9 replies  •  0 likes
dave-welch

Stopping a call does NOT work using the API explorer or our own code referencing the Sandbox or our code referencing Production. The Response code is 204 ("No content") and and the response headers are correct.


So, the DELETE method syntax and permissions are correct and the response is correct, but it does not hang up.


Anyone else having this problem?


Here is the Response from the Ring Out using API Explorer


{ "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/134133004/extension/134133004/ringout/...;,

"id": 62,

"status": {


"callStatus": "InProgress",

"callerStatus": "InProgress",

"calleeStatus": "InProgress"

}

}


Here is the code for the DELETE method using API Explorer


https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/ringout/62



Here is the Response Headers for the DELETE method

{

  "date": "Thu, 07 Apr 2016 19:09:12 GMT",
  "routingkey": "SJC12P01JWS02, SJC12P01PAS01",
  "content-language": "en",
  "content-type": "application/json; charset=UTF-8"

}





9 Answers
answered on Apr 19, 2016 at 2:44pm  
Awesome! Thanks for sharing Dave!

 0
answered on Apr 19, 2016 at 8:50am  
Probably the only thing that needs explanation is the Terminal Class.  This is an object that is instantiated for each extension and holds the relevant data like the CallId and the auth token 

 1
answered on Apr 19, 2016 at 8:46am  
      public String StopCall(Terminal _t)        {
            String sBody = String.Empty;
            byte[] byteBody = null;
            try
            {
                byteBody = new byte[2] { 123, 125 };
                SendReceive("DELETE", "/restapi/v1.0/account/~/extension/~/ringout/" + _t.CallId, "Bearer", _t.Access_Token, byteBody);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return String.Empty;
        }

      private void SendReceive(String method, String uri, String tokenType, String authcode, byte[] byteBody)
        {

            Stream sResponse = null;
            Stream sRequest = null;
            StreamReader srResponse = null;
            HttpWebResponse HttpWResp = null;
            String sBody = String.Empty;
            ASCIIEncoding encoding = new ASCIIEncoding();
            HttpWebRequest HttpWReq = null;
            try
            {
                HttpWReq = (HttpWebRequest)WebRequest.Create(baseURL + uri);
                HttpWReq.Method = method;
                HttpWReq.KeepAlive = true;
                if (tokenType.Trim().Length > 0 && authcode.Trim().Length > 0)
                {
                    HttpWReq.UserAgent = appName + "/" + appVersion;
                    HttpWReq.Headers[HttpRequestHeader.Authorization] = string.Format("{0} {1}", tokenType.Trim(), authcode.Trim());
                }
                if (HttpWReq.Method == "POST")
                {
                    if (HttpWReq.RequestUri.ToString().Contains("oauth/"))
                    {
                        HttpWReq.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
                    }
                    else
                    {
                        HttpWReq.ContentType = "application/json";
                    }

                    HttpWReq.ContentLength = byteBody.Length;

                    //Add parameters to the Body - Go figure
                    //Task<sRequest>HttpWReq.GetRequestStreamAsync();
                    sRequest = HttpWReq.GetRequestStream();
                    sRequest.Write(byteBody, 0, byteBody.Length);
                    //Console.WriteLine(sBody);
                }
                if (HttpWReq.Method == "DELETE")
                {
                    HttpWReq.Accept = "application/json";
                    HttpWReq.ContentType = "application/json; charset=UTF-8";
                    HttpWReq.Headers.Add("X-HTTP-Method-Override", "DELETE");

                }              
 //Send Request and Get the Response
                HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
                switch (HttpWResp.StatusCode.ToString())
                {
                    case "OK": //== HttpStatusCode.OK)

                        sResponse = HttpWResp.GetResponseStream();

                        srResponse = new StreamReader(sResponse);
                        String s = srResponse.ReadToEnd();

                        jt = JToken.Parse(s);
                        break;
                    case "NoContent":// Output from DELETE
                        break;
                    default:
                        break;

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("{0} {1}", ex.Message, ex.GetType().FullName));
            }
            finally
            {
                if (HttpWResp != null)
                {
                    HttpWResp.Close();
                }
                else
                {
                    HttpWReq.Abort();
                }
            }

        }

 1
answered on Apr 18, 2016 at 3:38pm  
Are you willing/able to share the code you wrote for that Dave?

 0
answered on Apr 14, 2016 at 9:42pm  
A long time ago I wrote a dialer that did not automatically disconnect a zombie call and a call was placed to Afghanistan for several days.  The bill was in the thousands.  Also, for totally hands free calling within an application, we would like to automatically hangup when the last page is entered.


 0
answered on Apr 13, 2016 at 2:58pm  
The person on the call would be required to hangup the call, AFAIK that is the only way, but I will ask around.

 0
answered on Apr 13, 2016 at 2:13pm  
I am trying to hangup the call.  This might happen at any point in the calling process.
From your previous comment, it seems that I misunderstood the purpose of this method.  If DELETE only works to stop a call before it has been answered, how do we hangup a call once it is answered?

 0
answered on Apr 13, 2016 at 1:38pm  
I've seen a thread of email going on about this inquiry, before I provide any more information on this, I have a question:

1. I see the state of the call is "InProgress", but when you initiate the DELETE request, is that being done before/during/after any leg of the call has been connected, and if yes, at which leg and what is the state (if observing the presence notifications) please?

The reason I ask is because currently, if the state of the call switches to "Ringing" that is considered as connected according to our current implementation and cannot be canceled. It seems this might need some improvement, but I'm trying to gather as much information as possible.


 0
answered on Apr 13, 2016 at 12:55pm  
Apologies for our API Explorer being out of sync with the API Developer Guide (which is more comprehensive, official, and shows the response body as empty on a DELETE to the route you provided).

https://developers.ringcentral.com/api-docs/latest/index.html#!#RefRingOut.html

I will take a look at the RingOut and canceling a RingOut and if I am able to recreate your experience will create an issue with our engineering team to inspect/resolve appropriately.

If I am unable to recreate, I may have some additional inquiries.

Thanks for providing the headers and request/response information.

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us