Hey everyone,
What I am trying to achieve is to upload a file from google drive to HubSpot ( Or Meta AdCreative as an example ). The problem I am facing - looks like I can’t get the correct format of the MediaObject to send to HubSpot. Errr I get “Error 415 Unsupported Media Type”
Here is what I’ve tried so far ( the basically I’ve tried to pass every single variable from this code below. In my ideal world I would just pass the Google Drive URL to the file, so it sends the data to HubSpot. But unfortunately it doesnt work like that.
I’ve tried to get contents of the file, get url, get_bytes(), get hash. All for nothing
Any hint would help, thanks!
Code Sample:
folder = app_files.ad_creatives
folder = folder.get("category1")
files = list(folder.list_files())
first_file_info = files[0]
file_upload = first_file_info.get_bytes()
image_url = first_file_info.url
print('image_url:',image_url)
# Convert the image URL to bytes and update the hash object
hash_object = hashlib.sha256()
hash_object.update(image_url.encode())
# Get the hexadecimal representation of the hash
image_hash = hash_object.hexdigest()