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
Message Store Export - name 'time' is not defined
Tags: sms
Mar 8, 2021 at 9:48am   •   5 replies  •  0 likes
Moez Tharani

I am using the python sample code from https://developers.ringcentral.com/guide/messaging/message-store/message-exports-report#python to try and export the message store. Using the exact same code, modified with my sandbox credentials and a later "dateTo", I get the following error. Any suggestions?

check task creation status ...
Traceback (most recent call last):
  File "sms.py", line 48, in <module>
    create_message_store_report()
  File "sms.py", line 15, in create_message_store_report
    get_message_store_report_task(json.id)
  File "sms.py", line 25, in get_message_store_report_task
    time.sleep(2)
NameError: name 'time' is not defined


5 Answers
answered on Mar 10, 2021 at 9:33pm  

Well the URL had a token in it. Regardless, the script itself is generating a 404 error.


 0
on Mar 10, 2021 at 9:39pm   •  0 likes

And this happens on your production account?

on Mar 10, 2021 at 9:44pm   •  0 likes

No, I don’t have a production account yet. I’m still trying to generate enough API calls to apply.

on Mar 10, 2021 at 9:47pm   •  0 likes

And you have SMS, voicemail or fax data on your sandbox?

on Mar 10, 2021 at 9:50pm   •  0 likes

Yes, a few sms messages.

answered on Mar 10, 2021 at 11:49am  

The status is Failed. How do I find out why the status is Failed?


 0
answered on Mar 10, 2021 at 9:03pm  

Ok, I figured out that the script was failing because my time range was too large. It seems to be successful now in generating an export, but when it goes to download it there is a 404 error. If I try and open the URL that is displayed by the script, I also get a 404 error. Any ideas?


 0
on Mar 10, 2021 at 9:20pm   •  0 likes

How did you download? Using exact code in the example? You cannot use the download url and open it from the browser unless you attach your access token to it.

answered on Mar 9, 2021 at 7:35pm  

Alright, I got that working. But now, the script just cycles through "check task creation status" until it exceeds the API limits. It doesn't actually do an export. And even though the analytics in my account shows over 1000 successful API calls, "status and review" shows "Your app hasn't made any API calls in Sandbox yet." All I'm trying to do here is export our SMS messages.


 0
on Mar 10, 2021 at 8:42am   •  0 likes

In the example, to keep it short, I assumed that the task would be created successfully after some time. So I don't check for other statuses. You should check other statuses and decide when to stop the loop.

Other task statuses: Accepted, Pending, InProgress, AttemptFailed, Failed, Completed, Cancelled

def get_message_store_report_task(taskId):
    print("check task creation status ...")
    endpoint = "/restapi/v1.0/account/~/message-store-report/" + taskId
    response = platform.get(endpoint)
    json = response.json()
    if json.status == "Completed":
        get_message_store_report_archive(taskId)
    else:
        time.sleep(2)
        get_message_store_report_task(taskId)

answered on Mar 8, 2021 at 3:01pm  

It is the Python standard lib. You just need to import the lib

import time


 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