question

Matthew Herbert avatar image
Matthew Herbert asked Matthew Herbert answered

Raw JSON to view call logs so I can see individual call recordings

Hi there

I am extremely new to this forum. I have signed up to the sandbox environment and wish to create some raw JSON to firstly "pass" a given telephone number and then to receive a response back with all the call recordings/call log list based on that telephone number. I have worked with raw JSON before but after extensive reading in the documentation I cannot see how to get started with the API. I want to use password flow authentication because I have solely created a CRM application (server-side application in the cloud) which will be doing the processing work, as opposed to a physical user. Ultimately all I want to do is allow my CRM application automatic"permission" to access the API and access the call recordings/log by passing the API a telephone number so I can then see the individual call recording IDs for that telephone number so ultimately a user in my CRM can play a call recording.

I believe the POST URL I need to access the API with password flow is as follows (an example):


Authorization: Basic cmVsLWFsbC1wZXJtaXNzaWXFjMmpRZmlQcnlkSUkweE92QQ== grant_type=password&username=18559100010&extension=101&password=121212

The username is the telephone number I was assigned when I signed up to the sandbox account and the password is my password I use to log into the sandbox account. However I am not sure what "cmVsLWFsbC1wZXJtaXNzaWXFjMmpRZmlQcnlkSUkweE92QQ" is in the example above which is provided by the documentation? Nor do I know what my "extension" is. Is this my extension or the telephone number I want to "pass" to the API in order to get the call logs belonging to that telephone number?

I do not have an account id too which is needed for other forms of authentication. My account manager says I will not get an account id until I send my application off to RingCentral for review and once accepted only then will I get an account ID?? My application is completely secure and server-side. It would be impossible to "send off" to anyone as it is an entire CRM application. That aside I think I can get it working by using the password flow authentication (as long as I don't need the account ID parameter at a later time?)


However I am stuck on how to "pass" the API a telephone number and get the response back with the resultant call log with each call recording ID belonging to that telephone number. Ultimately I need the call recording ID's so my user can play a call recording on the front end. I cannot find a clear example of simple working code in raw json to start working on my project . Please can anyone help?

Thank you very much for any help. I really appreciate it.

Matt

call recording
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anirban avatar image
Anirban answered Anirban commented
 cmVsLWFsbC1wZXJtaXNzaWXFjMmpRZmlQcnlkSUkweE92QQ== 

is the Base 64 encoding of your Client id and Client secret you need to encode in format of

Authorization Basic <clientId:clientSecret in Base64>

This is require to pass as authentication to get Oauth token. You will get the clent id and client secret in credentials section of your app.

You can check your account id number with this following API:

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

You will get account id and extension id in response

8 comments
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Hi I am sorry but I have another question please: in your comment above

                    
  1. cmVsLWFsbC1wZXJtaXNzaWXFjMmpRZmlQcnlkSUkweE92QQ== 

is the Base 64 encoding of your Client id and Client secret you need to encode in format of

                    
  1. Authorization Basic <clientId:clientSecret in Base64>



I have got my client ID and client secret from my app settings. Please can you tell me how I pass this to Postman - do I POST it like follows:

Authorization: Basic <MY CLIENT ID>:<MY CLIENT SECRET>== grant_type=password&username=18559100010&extension=101&password=121212

(Replacing MY CLIENT ID with my client ID and replacing MY CLIENT SECRET with my client secret? So both the client id and client secret are just separated by a colon ":"? I have tried to "POST" this in Postman but without success. When I have used Postman before the POST field normally only takes one line, normally in the form of a URL with querystrings or query parameters.

Thank you for any help.

0 Likes 0 ·

Simple example... suppose your client id is abcdefgijklmnoaczxcxzccd and client secret is efghijk123rtyui, got to https://www.base64encode.org/ and select encode...

put the value abcdefgijklmnoaczxcxzccd:efghijk123rtyui there separated by colon.

When you press encode button, you will get encoded value:

YWJjZGVmZ2lqa2xtbm9hY3p4Y3h6Y2NkOmVmZ2hpamsxMjNydHl1aSA=

Now you can use this value in Header as

Authorization   Basic YWJjZGVmZ2lqa2xtbm9hY3p4Y3h6Y2NkOmVmZ2hpamsxMjNydHl1aSA=

in body pass:

username=+18559100010&password=121212&extension=101&grant_type=password

url: https://platform.devtest.ringcentral.com/restapi/oauth/token (if you are using Sandbox)


You will able to generate access_token in response which you can pass in other APIs as Bearer type

Authorization Bearer <access_token>  

example

pass it in "https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~ " call as header

1 Like 1 ·

Thank you so much for your answer. That was really helpful and I am now getting it to work however my Postman error is saying the following:


{

"error" : "unauthorized_client",

"errors" : [ {

"errorCode" : "OAU-251",

"message" : "Unauthorized for this grant type"

} ],

"error_description" : "Unauthorized for this grant type"

}


I have checked and double checked the BODY line in Postman:

username=+<MY PROVIDED TEL NUMBER>&password=<MY PASSWORD TO LOGIN TO SANDBOX>&extension=101&grant_type=password

I can login fine with the credentials when logging into the RingCentral Sandbox web page but it may be a syntax issue in Postman.

0 Likes 0 ·
Show more comments
Matthew Herbert avatar image
Matthew Herbert answered

Thank you for your help Anirban. I will give it a go and see how I get on.

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Matthew Herbert avatar image
Matthew Herbert answered Matthew Herbert edited

Does anyone have any working examples of accessing a call log by passing a telephone number querystring and the individual call recordings related to that telephone number?

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Matthew Herbert avatar image
Matthew Herbert answered Anirban edited

@Anirban How do I carry out the part you suggested to get my account number and extension:


"https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~ " Where do I run this? I have Postman so can run test code there. But surely I need something to unique to identify me in order to run this generic line of code?

1 comment
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

This is a GET method you can run in postman with the url.

You just need to pass access token you got it from previous https://platform.devtest.ringcentral.com/restapi/oauth/token call

Once you get the token you call GET https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~ and pass the access token in Header :-

Authorization Bearer <access_token>

You will get a response something like this example:

{
    "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/123456789/extension/987654321",
    "id": 123456789,
.....

123456789 will be account id and 987654321 will be extension id

1 Like 1 ·
Matthew Herbert avatar image
Matthew Herbert answered

Thank you for your help with this. I really appreciate it.

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Matthew Herbert avatar image
Matthew Herbert answered Matthew Herbert edited

@Anirban Thank you. I will use the clone option next time.

It's working and can get my account ID by using the access token I received earlier. I am now trying to access the Call Log. I have downloaded RingCentral's soft phone desktop application and have made an INBOUND call using my cell/mobile phone to my developer test telephone number, which works, and I have recorded two or three inbound calls. I cannot make test outbound calls because I'm on a test developer account. My app has Read Call Log permission .


When I run the following GET command:

https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/call-log HTTP/1.1


And use the following headers:

Content-Type: application/json 
Accept: application/json 
Authorization: Bearer <MY ACCESS TOKEN> 
Host: platform.devtest.ringcentral.com

Nothing entered in the Body.

When I click Send in Postman I get the following error message:

{     "errorCode": "AGW-404",     "message": "Resource not found",     "errors": [] 
}


2 comments
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Are you putting HTTP/1.1 in url? Check the correct url. You dont to to put entire HTTP/1.1 in url

1 Like 1 ·

Brilliant, that worked! I can see the call log. Thank you for your help. The documentation on https://developers.ringcentral.com/guide/voice/call-log/api specify the HTTP/1.1 in the GET command URL. However I have removed it as you suggested and now it is all working. Thank you very much for your time to help me. I really appreciate it.

0 Likes 0 ·
Matthew Herbert avatar image
Matthew Herbert answered

@Anirban please can you tell me how I can use Postman to "pass" an example telephone number and pass an example "dateFrom" to my app so I can return the call log only for that telephone number for all results received on or after the specified "dateFrom" value? Currently I am able to return the whole entire call log but I want to be able to query and filter to show all results in the logs for a particular telephone number and dateFrom value and even dateTo value if possible.

Thank you for any help. I really appreciate it.

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys