Cant extract report data from API

217 views
Skip to first unread message

HYPR Plataforma

unread,
Jun 23, 2023, 2:19:00 PM6/23/23
to Google's Campaign Manager 360 API Forum

Every call that i do to ask a report, it returns a blank bytes result

here's my example code:

credentials = ServiceAccountCredentials.from_json_keyfile_name(
    filename = '../../service_account.json',
)

service = discovery.build('displayvideo', 'v2', credentials=credentials)
createSdfDownloadTaskRequest  = {
    'advertiserId': 1218096228,
    'parentEntityFilter': {
        'fileType': 'FILE_TYPE_CAMPAIGN',
        'filterType': 'FILTER_TYPE_NONE'
    }
}
try:
    operation = service.sdfdownloadtasks().create(body=createSdfDownloadTaskRequest).execute()
except googleapiclient.errors.HttpError as e:
    print("An HTTP error occurred:", e)
    print("Error details:", e.content.decode())
except Exception as e:
    print("An error occurred:", e)

resource_created = False
wait_seconds = 10
max_trials = 5

resource_trial = 0

while not resource_created:

    if resource_trial >= max_trials:
        print("max trials achieved trying to create operation resource for collect report data")
        break

    operation_result = service.sdfdownloadtasks().operations().get(name = operation['name']).execute()
   
    if 'done' in operation_result:
        if 'error' in operation_result:
            print(f"cant create report operation request {operation['error']['code']} - {operation['error']['message']}")
        else:
            resource_created = True
    else:
        time.sleep(wait_seconds)
        resource_trial += 1

resource_name = operation_result['response']['resourceName']
download_request = service.media().download_media(resourceName=resource_name)

file_stream = io.BytesIO()
downloader = MediaIoBaseDownload(file_stream, download_request)

download_finished = False
while not download_finished:
    status, download_finished = downloader.next_chunk()
    print("Download %d%%." % int(status.progress() * 100))


everything runs without any error, but at the end:

file_stream.read() returns: b''

what i'm doing wrong here?

DCM API (DoubleClick Campaign Mgr)

unread,
Jun 26, 2023, 5:28:34 AM6/26/23
to plat...@hypr.systems, google-doubleclick-...@googlegroups.com

Hi,

Thanks for reaching out. I've reviewed your code, and I can see that you are trying to access the Display & Video 360 (DV360) API. However, our support team only supports the Campaign Manager 360 (CM360) API.

The DV360 API is a different product, and we don't have the expertise to help you with it. I recommend that you reach out to the DV360 support team for help with your issue.

Here is the link to the DV360 API support page: https://developers.google.com/display-video/api/support
 

This message is in relation to case "ref:_00D1U1174p._5004Q2mWykg:ref"

Thanks,
 
Google Logo DCM API Team

 



Reply all
Reply to author
Forward
0 new messages