question

Luisa Medina avatar image
Luisa Medina asked Phong Vu commented

Not retrieving any data when using SDK python

I am using ringcentral SDK to authenticate and retrieve the call report. I am trying to get the detailed call report from the past six months for all users (I created the sandbox credentials and I am super admin as well), I need both inbound and outbound calls.. Below is a snippet of the code I am using to retrieve the call report, however, when I run my code I encounter that no call records are being retrieved. This is the code I am using:

params = {'view': 'Detailed', 'dateFrom' : start_date, 'dateTo' : date_today, 'perPage' : 1000, 'type' : 'Voice'} 
response = platform.get(f'/restapi/v1.0/account/~/extension/~/call-log?view=Detailed', params) status_code = response.response().status_code print('status code', status_code) -> This prints a 200 response which is a successful call. 
response_content = response.text() 
try: 
   response_data = response.json_dict() 
except json.JSONDecodeError as e: 
   print(f'failed to parse JSON response:, {e}') 
response_data = response.json_dict() 
call_records = response_data.get('records', []) 
print('call records', call_records) 


When I run the code I get an empty list on call_records which means no data is being retrieved. I know the data is there because I can manually download the call report but I am not sure what the error is when retrieving the data using the API.

rest apisdkcall logs
1 |3000

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

Phong Vu avatar image
Phong Vu answered

There are couples mistakes in your code. Fix it as follow and try again

params = {
 'view': 'Detailed', 
 'dateFrom' : start_date, 
 'dateTo' : date_today,
 'perPage' : 1000, 
 'type' : ['Voice']
} 
response = platform.get('/restapi/v1.0/account/~/call-log', params) 

As a super admin, you can read the company call log and I think that is what you want to achieve. Of course you can call the user call log '/restapi/v1.0/account/~/extension/~/call-log' but it could be that that user does not have any call data during the dateFrom and dateTo period.

1 |3000

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

Luisa Medina avatar image
Luisa Medina answered Phong Vu commented

Thank you for your reply! I know my user doesn't have any call data but since I am trying to retrieve the company's call data it doesn't make sense that it doesn't find any data.


I tried your suggestion but I am still getting empty records. Is there anything else I could try or maybe something I might be doing wrong?


Thanks

1684421843155.png


1684421843155.png (93.0 KiB)
1 comment
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·

Checking your sandbox account I see nothing in the last 60 days. You wrote that you could manually download the report, where and how did you download it.

Here is your sandbox account admin call log dashboard.

screen-shot-2023-05-18-at-81005-am.png

0 Likes 0 ·
Luisa Medina avatar image
Luisa Medina answered Phong Vu commented

As I mentioned my number and extension don't have any calls to be retrieved, I am aiming to retrieve the company's call log and not my number call log. The company's call log I am able to download it manually from the reports tab and I know it has records that go back at least for the past six months.

1 comment
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·

I think you confuse between your production account and your sandbox account. You might download the call log report from your production account, while you try to read your call log from your sandbox account.

The screenshot I posted is your sandbox account for account level and it's empty.

To read the call log from your production account using the code, you have to graduate your app to production, grab the production app client id and client secret and authenticate your app with a super admin user from your production account.

0 Likes 0 ·

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