Legacy Dev Forum Posts

 View Only

Sign Up

PureCloudPlatformClientV2.OutboundApi() how to extract data

  • 1.  PureCloudPlatformClientV2.OutboundApi() how to extract data

    Posted 06-05-2025 18:09

    mihail | 2023-03-28 08:46:37 UTC | #1

    Hi,

    I am trying to export the contact list data for a specific Contact list ID, but I am trying to figure out why the data from the URI I am reading is HTML?

    The below python script seems to work fine. When I manually click on the api_response.uri link it does download the required data in .CSV file When i try to read the csv file from the URI within the python script, it returns a HTML file.

    Below is the script I am using. Any thoughts on how I can load this file in python?

    import os from PureCloudPlatformClientV2.rest import ApiException from pprint import pprint import datetime import logging import requests import json import certifi import os from datetime import date import time import csv import inspect import pandas as pd

    region = PureCloudPlatformClientV2.PureCloudRegionHosts.euwest1 PureCloudPlatformClientV2.configuration.host = region.getapihost()

    GENESYSCLOUDCLIENTID = 'x' GENESYSCLOUDCLIENTSECRET = 'x'

    apiclient = PureCloudPlatformClientV2.apiclient.ApiClient().getclientcredentialstoken(GENESYSCLOUDCLIENTID,GENESYSCLOUDCLIENTSECRET) #print(apiclient.accesstoken) PureCloudPlatformClientV2.configuration.accesstoken = apiclient.access_token

    create an instance of the API class apiinstance = PureCloudPlatformClientV2.OutboundApi() contactlist_id = 'x' # str | Contactlist ID

    try: # Get a basic ContactList information object apiresponse = apiinstance.getoutboundcontactlistexport(contactlistid) pprint(apiresponse) exporturi = apiresponse.uri pprint(exporturi) #dataset = pd.readcsv(export_uri,sep=",") #display(dataset)

    except ApiException as e: print("Exception when calling GetOutboundContactlistsDivisionviewRequest->getoutboundcontactlists_divisionview: %s\n" % e)


    charlie.conneely | 2023-03-28 12:57:48 UTC | #2

    Hello

    When you invoke get_outbound_contactlist_export(), you receive the download uri. At the end of this URI is the download ID. You can then use this download ID in a call to GET /api/v2/downloads/{downloadId}. (You will see an example of this operation using the python sdk in this link.). This will return the download URI that will download the csv data to your machine on a basic GET request.

    Hope this helps, Charlie


    mihail | 2023-03-28 14:15:03 UTC | #3

    Hi Charlie,

    Thanks for pointing me in the right direction. I think the link you sent brings you to the old documentation but I was able to get a little further by following the example here: https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudpython/DownloadsApi

    apiinstancedownload = PureCloudPlatformClientV2.DownloadsApi() downloadid = 'x' # str | Download ID #contentdisposition = 'contentdispositionexample' # str | (optional) #issueredirect = True # bool | (optional) (default to True) #redirectto_auth = True # bool | (optional) (default to True)

    try: # Issues a redirect to a signed secure download URL for specified download apiresponsedownload = apiinstancedownload.getdownload(downloadid) pprint(apiresponsedownload) pprint(apiresponsedownload.url) except ApiException as e: print("Exception when calling DownloadsApi->get_download: %s\n" % e)

    When i print the apiresponsedownload.url from above script it retrurns "None"

    I am wondering why that might be as the download_id I am passing in seems to be correct.

    Thanks, Mihail


    charlie.conneely | 2023-03-29 07:30:54 UTC | #4

    Hi Mihail

    The example you provided above worked for me after I set issue_redirect and redirect_to_auth to False.

    Hope this helps, Charlie


    mihail | 2023-03-29 07:30:52 UTC | #5

    Hi Charlie,

    yes, setting the 2 parameters to False worked.

    Thanks for your help.

    Regards, Mihail


    system | 2023-04-29 07:31:16 UTC | #6

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 19166