I want to use the ring-out restful api. I can get a token but get error calling api

  • 1
  • Question
  • Updated 4 months ago

I want to use the ring-out restful API. I have written the code to successfully return a access token, but when I take the token and call the ring-out api I get the reasonphrase "Not Found"

this is what my url looks like: 

'https://platform.devtest.ringcentral.com/restapi/v1.0/account/%2b+13136366191/extension/101/ring-out'

and my json I post:

{\"from\": {\"phoneNumber\": \"+13136366191\", \"forwardingNumberId\": \"\"}, \"to\": {\"phoneNumber\": \"+17134178892\", \"callerid\": \"\"}, \"playPrompt\": true, \"country\": { \"id\" : \"\" } }

Not sure what I am doing wrong. 

I can share code if need be. 


Thank you in Advance



Photo of Tim Martin

Tim Martin

  • 80 Points 75 badge 2x thumb

Posted 5 months ago

  • 1
Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 2,674 Points 2k badge 2x thumb
Tim,

please read this to understand better how resources are addressed in our REST API: https://developer.ringcentral.com/api-docs/latest/index.html#!#Resources.html

Your mistake is the way how you are referring to account and extension in URI. You should use internal ID or tilde, not phone number/extension number.
Photo of Paco Vu

Paco Vu

  • 426 Points 250 badge 2x thumb
Hi Tim,

You have some redundant parameters without values. Try this instead

{"from": {"phoneNumber": "+13136366191"}, "to": {"phoneNumber": "+17134178892"}, "callerid": "+13136366191"}, "playPrompt": true }

+ Phong
Photo of Tyler Long

Tyler Long, Official Rep

  • 6,374 Points 5k badge 2x thumb
https://platform.devtest.ringcentral.com/restapi/v1.0/account/%2b+13136366191/extension/101/ring-out

In the uri above, account ID and extension ID are invalid. They should be internal IDs. Or you can use "~" to indicate the current account and extension: https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/ring-out'
Photo of Tim Martin

Tim Martin

  • 80 Points 75 badge 2x thumb
Sorry I am just now getting back to this, but what do you mean internal IDs, main phone number and extension?

The app I created is a server only app and I am attempting to force a call via our CRM (click to call application).  I have tried every thing i can think of.  this is my latest attempt.  

Json
{"from":{"phoneNumber":"+17134178892"},"to":{"phoneNumber":"+17132753591"},"playPrompt":true}

Request
{Method: POST, RequestUri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/ring-out', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
  Accept: application/json
  Authorization: Bearer U0pDMTFQMDFQQVMwMHxBQUNPS09XNS1IYTlMQ1dQRnBjbC0zc3dxbkx1QlVFVlJBY24tdmg1QVpKV0ZmbW13V2Q4elNReTJNc1dHSUNLMG5SNF9QWWRPMEVYNEhPV3FzbEwwTUtuTXExWklRMzhUcm84RWFEc3FFZ0lVRkl6Z2RaZzc5RDE4Z1hnZGxLX0M4amZVc194TDlMd1FSbFg2Z29OZ2NhWEtYelBCdEJqd2swbm1UbmNfSmhmNnZaZTZYVTZ6LVRLM1paODIwY09EQ2N8eWxWN3l3fHFRcXhrYjJXd0ZoV3JSNEU4bS03NGc
  Content-Type: application/json; charset=utf-8
  Content-Length: 110
}}

Response
{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Connection: keep-alive
  RCRequestId: 9a579238-3d8a-11e8-8369-005056bb594d
  RoutingKey: SJC11P01PAS02
  X-Rate-Limit-Group: heavy
  X-Rate-Limit-Limit: 10
  X-Rate-Limit-Remaining: 9
  X-Rate-Limit-Window: 60
  Date: Wed, 11 Apr 2018 13:16:54 GMT
  Server: nginx/1.10.2
  Content-Length: 236
  Content-Language: en-US
  Content-Type: application/json; charset=UTF-8
}}

Again, i can get my token using grant type = password without any problem.  I just can't seem to get the ring-out to work

Is there any thing that should be running on my desktop, link Ring Central for windows?

Thank you again and I appreciate your thoughts and ideas.

Tim Martin
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,996 Points 5k badge 2x thumb
You are writing C#. Do you want to use the official library: https://github.com/ringcentral/ringcentral-csharp-client ? it will make your life easier.

For the response you post above. Could you please read the content out of "Content: System.Net.Http.StreamContent". Then we can get a detailed error message and we will know what happened.
(Edited)