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
AGW-401 Error when I click on recording contentURI
Tags: authentication, call logs
Mar 12, 2023 at 10:05am   •   1 replies  •  0 likes
Josh Pesikoff

Hello,

I am trying to create an app that downloads our call logs and stores them in an interna database. Right now, I have a sandbox app that calls the Call Log API that has 3 dummy calls that I made myself. I can call them from the API , but when I try to visit the recording content URI of any of the calls, I met with this error:

{
  "errorCode": "AGW-401",
  "message": "Authorization header is not specified",
  "errors": [
    {
      "errorCode": "AGW-401",
      "message": "Authorization header is not specified"
    }
  ]
}

Any idea how I can solve this? I think it may be related to getting an access token? I have read that I need one, but have just been using the SDK to login. See below


from ringcentral import SDK
 
 
RINGCENTRAL_CLIENTID = 'my id'
RINGCENTRAL_CLIENTSECRET =  'my secret' 
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'
 
rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER)
platform = rcsdk.platform()
 
JWT_TOKEN = 'my jwt'
 
try:
    platform.login( jwt=JWT_TOKEN )
    
    resp = platform.get('/restapi/v1.0/account/~/extension/~/call-log')
    print(resp.text())
except Exception as e:
    print ("Unable to authenticate to platform. Check credentials." + str(e))
1 Answer
answered on Mar 13, 2023 at 7:52am  

You wrote that you could read your call log, but you cannot download call recordings. However, you showed only the code where you read the call log?

Any way, here is an example code how to read the call log and download call recordings, provided that you have the call recording and your app has the read call recording.

def read_account_call_log():
    path = os.getcwd() + "/recording_content/"
    if not os.path.isdir(path):
        print("create folder")
        try:
            os.mkdir(path)
        except OSError as e:
            print(e)

    params = {
        'dateFrom': "2023-01-01T00:00:00.000Z",
        'dateTo': "2023-03-01T00:00:00.000Z",
        'perPage': 1000
    }
    resp = platform.get('/restapi/v1.0/account/~/call-log', params)
    jsonObj = resp.json()

    for record in jsonObj.records:
        if hasattr(record, 'recording'):
            fileName = str(record.recording.id) + ".mp3"
            try:
                res = platform.get(record.recording.contentUri)
                file = open(("%s%s" % (path, fileName)),'wb')
                file.write(res.body())
                file.close()
                print ("Call recording saved in " + fileName)
            except ApiException as e:
                print (e.getMessage())

 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