How can I download call log between two defined date using python or Js

  • 1
  • Question
  • Updated 5 months ago
  • Answered
Hi, I have my APP_KEY, APP_SECRET, USERNAME, PASSWORD.
I have also a little knowledge of python. I want to download detail call log without fax and Inbound calls between two defined date.
Any idea or sample script will be very helpful for me.
Thanks
Photo of Atik R

Atik R

  • 168 Points 100 badge 2x thumb

Posted 5 months ago

  • 1
Photo of John Wang

John Wang, Official Rep

  • 5,654 Points 5k badge 2x thumb
When making a call to the call-log end point, set the following query parameters:

  • dateFrom
  • dateTo
  • direction = 'Outbound'
  • type = 'Voice'
  • view = 'Detailed'

See this example in Python here:

https://github.com/grokify/ringcentral-python-examples/blob/master/demo_call-log.py
(Edited)
Photo of Atik R

Atik R

  • 168 Points 100 badge 2x thumb
Hi Sir, 
Thanks for your help with the code, I have tried but getting an error, Actually I am confused where I need to put my login details and secret keys etc. Here I have added my code and error found. 
Thanks

Here is my code sample:

import os
from dotenv import load_dotenv
load_dotenv(dotenv_path=os.getenv('ENV_PATH'))

from ringcentral import SDK

sdk = SDK(
os.getenv('MyClientId'),
os.getenv('Mysecret Key'),
os.getenv('https://platform.devtest.ringcentral.com'))

platform = sdk.platform()
platform.login(
os.getenv('MyUsername'),
os.getenv('MyExtention'),
os.getenv('MyPassword'))


try:
from urllib import urlencode
except: # For Python 3
from urllib.parse import urlencode

query = {
'dateFrom': '2018-05-01T00:00:00Z',
'dateTo': '2018-06-01T00:00:00Z',
'direction': 'Outbound',
'type': 'Voice',
'view': 'Detailed'}

qs = urlencode(query)

res = platform.get('/restapi/v1.0/account/~/extension/~/call-log?'+qs)
print(res.text())

Here is the error: 
Traceback (most recent call last):
  File "C:/Python34/Ringcentral.py", line 20, in <module>
    os.getenv('MyPassword'))
  File "C:\Python34\lib\site-packages\ringcentral\platform\platform.py", line 105, in login
    raise e
  File "C:\Python34\lib\site-packages\ringcentral\platform\platform.py", line 82, in login
    raise Exception('Either code or username with password has to be provided')
Exception: Either code or username with password has to be provided
Photo of John Wang

John Wang, Official Rep

  • 5,622 Points 5k badge 2x thumb
Could the issue be you are currently making API calls to the sandbox account and your calls are in your production account?

You are currently making API calls against your sandbox account:
When you log into the associated Online Account Portal account (note the .devtest) in the host name, do you see calls in the Call Log report?

To make some calls in the sandbox, you can reset your RingCentral for Desktop softphone to log into your sandbox account and make/receive calls. More information is available on this here:
If you are trying to see calls you made in your production account, you will need to graduate your app and then update your app and user credentials.
(Edited)
Photo of Atik R

Atik R

  • 168 Points 100 badge 2x thumb
Hello Sir,
You are awesome...!
I have updated my app to Production and it's working perfectly for call log now.
I have created another app for reading meeting list And getting this error bellow.
Although I have set permission for Meetings.


{ "errorCode": "CMN-408", "message": "In order to call this API endpoint, user needs to have [Meetings] permission for requested resource.", "errors": [ { "errorCode": "CMN-408", "message": "In order to call this API endpoint, user needs to have [Meetings] permission for requested resource.", "permissionName": "Meetings" } ], "permissionName": "Meetings" }
(Edited)
Photo of John Wang

John Wang, Official Rep

  • 5,622 Points 5k badge 2x thumb
RingCentral has two sets of permissions, app permissions and user permissions. This specific error says "user needs" so this is a user permission. To verify the user you are using has this permission, go to the Online Account Portal:

* Sandbox: https://service.devtest.ringcentral.com
* Production: https://service.ringcentral.com

Go to "Users" > "Roles" and ensure the user that authorized the app has the "Meetings App Access" permission.

https://success.ringcentral.com/articles/RC_Knowledge_Article/5-10-Editing-the-Extension-Permissions...

Here's what the permission looks like in the UI:
I posted a bit more on this here:

https://stackoverflow.com/questions/50977970/ringcentral-meetings-api-error-user-needs-to-have-meeti...
(Edited)
Photo of Atik R

Atik R

  • 168 Points 100 badge 2x thumb
Hi, Thanks a lot for helping me sir.
Now it's working perfectly.
Thanks you very much sir.
One more question sir- Can i change time zone while making API call like GMT-7? As Timestamp logged in RingCentral is GTM time.

Many Thanks
Photo of Atik R

Atik R

  • 168 Points 100 badge 2x thumb
Hi, Thanks Problem solve....!