0

I am using zeep to connect to the Five9 Call Center API in order to retrieve the Call Log Report.

My code is as follows:

class Five9api:

    start = (datetime.now() - timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
    end = datetime.now()
    user = 'user'
    pwd = 'pwd'
    criteria = {'time': {'end': end, 'start': start}}
    key = None

    def __init__(self, folderName, reportName):
        self.client = None
        self.folderName = folderName
        self.reportName = reportName

    def open_client(self):
        if self.client is None:
            self.client = Five9(self.user, self.pwd)

    def run_report(self):
        identifier = self.client.configuration.runReport(folderName=self.folderName, reportName=self.reportName,
                                                        criteria=self.criteria)
        Five9api.key = identifier

    def get_report_results(self):
        get_results = self.client.configuration.getReportResult(Five9api.key)

        return get_results

I am getting an Error when I use the method run_report to return a key that is passed onto the method get_report_results. What is causing this following error?

zeep.exceptions.Fault: Result is not ready due to process is not complete

The only way around this error is to introduce a time.sleep between the aforementioned 2 methods like so...

Report = Five9api("Call Log Reports", "Call Log")
Report.open_client()
Report.run_report()
time.sleep(5)
data = Report.get_report_results()
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Riley Hun
  • 2,541
  • 5
  • 31
  • 77

1 Answers1

0

Before you retrieve report results with getReportResult, you can check if it's ready with isReportRunning method:

def get_report_results(self):
    while client.service.isReportRunning(identifier=Five9api.key, timeout=100):
        None
    get_results = self.client.configuration.getReportResult(Five9api.key)

See full documentation here: Configuration Web Services, API Reference Guide

Milos
  • 192
  • 3
  • 11