Hello everyone, we would like to import PDFs into Hubspot and create an association to a custom object data set via API so that the PDF can be called up on the data set under Attachment.
Is this approach correct?
def associate_file(file_id, record_id):
url = f"
https://api.hubapi.com/crm/v3/associations/files{CUSTOM_OBJECT_TYPE_ID}/batch/create"
payload = {
"inputs": [
{
"from": {"id": file_id},
"to": {"id": record_id},
"type": "file_to_custom"
}
]
}
response = requests.put(url, headers={**HEADERS, "Content-Type": "application/json"}, json=payload)
if response.status_code == 200:
print(f" Datei {file_id} mit Datensatz {record_id} verknüpft!")
else:
print(f" Fehler bei der Verknüpfung: {response.text}")
best regards
Martin