DFA report download via API

156 views
Skip to first unread message

Vishwanath Srinivasan

unread,
Jun 21, 2015, 2:02:40 PM6/21/15
to google-doubleclick-...@googlegroups.com
Hi All,

I'm new to the DFA API and have a dumb question that I am hoping someone can help me with - I am able to get the links to download files successfully eg.:

{
    "kind": "storage#object",
    "id": "dfa_-065ae7332a9d60c7b84892abbe1eaa474d268109/NetworkClick_8984_01-01-2014.log.gz/138862818193000",
    "name": "NetworkClick_8984_01-01-2014.log.gz",
    "bucket": "dfa_-065ae7332a9d60c7b84892abbe1eaa474d268109",
    "generation": "1388628181930000",
    "metageneration": "1",
    "contentType": "application/zip",
    "updated": "2014-01-02T02:03:01.929Z",
    "size": "15855",
    "md5Hash": "Rn67l52ZSRy0UZ+f7X21/g==",
    "owner": {
        "entity": "user-00b4903a977ace082fbdea3a84f04b3bba5c0eb7cca47701139b65a37d066911",
        "entityId": "00b4903a977ace082fbdea3a84f04b3bba5c0eb7cca47701139b65a37d066911"
    },
    "crc32c": "TK7UQQ==",
    "etag": "CJCgiYyz3rsCEAE="
}

But when I get the media link, I get content that says is application/zip but I when I try to decompress it I keep getting invalid zip messages. I have tried application/gzip, application/octet-stream etc. and the data coming back doesn't seem to be valid (I thought it was chunked initially but am ensuring I get the entire content back). 

url = 'https://www.googleapis.com/download/storage/v1/b/dfa_-065ae7332a9d60c7b84892abbe1eaa474d268109/o/NetworkClick_8984_01-01-2014.log.gz?generation=138862818193000&alt=media'
           request
= urllib2.Request(url)          
           request
.add_header("Authorization", "Bearer ya29.mQGyHfoObYrbmWJoEpDD1LMvHPCYRQK0zrSgs527iK8Lvm_YpXIEE796yfm3XeslSfSHk113zjj0B")
           request
.add_header('Accept-encoding', 'zip')
           request
.add_header('Content-disposition', 'attachment')
           result
= urllib2.urlopen(request)
           response
=""
           
while 1:
               packet
= result.read()
               
if not packet:
                   
break
               response
+= packet
           result
.close()
           buffer
= StringIO.StringIO(response)
           file
= zipfile.ZipFile(buffer, "r")
           
#gzipper = gzip.GzipFile(fileobj=content)
           decompressed_data
=zlib.decompress(response)

zipfile.BadZipfile: File is not a zip file is the error I keep getting back. Is there an easier way to get this file?

thanks a lot for your help in advance!

thanks,
Vish.



Poh Soon Yap

unread,
Jun 21, 2015, 7:55:10 PM6/21/15
to google-doubleclick-...@googlegroups.com
Hi,

My guest, because the file is a plain file, and is not zipped at all.  Thats my guest because i too, unable to get DCM to zip (in java) :(
--
You received this message because you are subscribed to the Google Groups "Google's DoubleClick for Advertisers API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-doubleclick-for-ad...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonathon Imperiosi (DCM API Team)

unread,
Jun 22, 2015, 11:05:18 AM6/22/15
to google-doubleclick-...@googlegroups.com, vsrin...@snaplogic.com
Hi Vish,

It looks like you're working with data transfer files, which is unfortunately outside the scope of what we support here on this forum. Your best bet for questions like this is to contact your account manager or DCM support.

As Poh mentioned, it may be that the response isn't actually zipped. There are instructions here on enabling gzip compression for DCM API requests, however I'm not sure if this is the same for Google Cloud Storage requests.

Regards,
- Jonathon Imperiosi, DCM API Team

Vishwanath Srinivasan

unread,
Jun 22, 2015, 12:40:52 PM6/22/15
to google-doubleclick-...@googlegroups.com
Thanks for the replies Jonathon and Poh. I know for a fact it is compressed data (it doesn't look like plain text either) and the type seems to say application/zip but am not able to decompress that way. I will try reaching out to our account manager and see if they can assist.

thanks!

--
You received this message because you are subscribed to a topic in the Google Groups "Google's DoubleClick for Advertisers API Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-doubleclick-for-advertisers-api/IFIw0fxWG4c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-doubleclick-for-ad...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Vish Srinivasan | m: 408.202.2499 | Solutions Engineer | SnapLogic
Reply all
Reply to author
Forward
0 new messages