I'm using Hubspot workflows, specifically one of the custom code modules. I'm trying to import the PublicMergeInput class into my python 3.9 custom code.
I am getting an ImportModuleError... cannot import name 'PublicMergeInput' from 'hubspot.crm.contacts'
It is not working on any of the hubspot clients offered (v4,v7,v8).
Is this functionality not supported in Workflows? I have been successfull using it outside of workflows in a python enviornment.
Here is what the code looks like up top...
import hubspot import os from hubspot.crm.contacts import PublicMergeInput from hubspot.events import ApiException
I wasn't able to reproduce the issue you're experiencing. Here's my custom code that successfully merged 2 Contacts (Python 3.9, HubSpot Client v8):
import hubspot
import os
from hubspot.crm.contacts import PublicMergeInput, ApiException
client = hubspot.Client.create(access_token=os.environ["your_hs_pat_secret_name"])
def main(event):
public_merge_input = PublicMergeInput(object_id_to_merge="12345", primary_object_id="67890") # these are placeholder contact record ids
try:
api_response = client.crm.contacts.public_object_api.merge(public_merge_input=public_merge_input) # note that the "public_object_api" was renamed to "merge_api" in V10, so HS API documentation example doesn't work as is
print(api_response)
except ApiException as e:
print("Exception when calling merge_api->merge: %s\n" % e)
raise
# Return the output data that can be used in later actions in your workflow.
return {
"outputFields": {
"example": "example"
}
}
I hope that proves helpful. Please let me know if you have any follow-up questions.
All the best,
Zach
--
Zach Klein HubSpot Integrations & App Developer Meanjin / Brisbane, Australia