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
Not retrieving any data when using SDK python
Tags: sdk, rest api, call logs
May 18, 2023 at 2:03am   •   3 replies  •  0 likes
Luisa Medina

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.

3 Answers
answered on May 18, 2023 at 8:17am  

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.


 0
on May 18, 2023 at 9:42am   •  0 likes

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.

answered on May 18, 2023 at 7:57am  

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


 0
on May 18, 2023 at 8:12am   •  0 likes

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

answered on May 18, 2023 at 7:18am  

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.


 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