<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create workflow using customcode - python script in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/934342#M71496</link>
    <description>&lt;P&gt;Thank you for your rep,&lt;/P&gt;&lt;P&gt;I resolved the issue by using another service - Azure Automation Account, and I will Hubspot webhook instead of Hubspot customcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now, i have another script, the script will call to hubspot api and it works well locally but got SSL issue on Azure Automation Account.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Traceback (most recent call last): File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn conn.connect() File "C:\userenv\lib\site-packages\urllib3\connection.py", line 653, in connect sock_and_verified = _ssl_wrap_socket_and_match_hostname( File "C:\userenv\lib\site-packages\urllib3\connection.py", line 806, in _ssl_wrap_socket_and_match_hostname ssl_sock = ssl_wrap_socket( File "C:\userenv\lib\site-packages\urllib3\util\ssl_.py", line 465, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname) File "C:\userenv\lib\site-packages\urllib3\util\ssl_.py", line 509, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Python\lib\ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "C:\Python\lib\ssl.py", line 1040, in _create self.do_handshake() File "C:\Python\lib\ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen response = self._make_request( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/tmp/94079701-23ba-4aab-877d-d1b7f0ba2be3/runbooks/azuredevops.py", line 15, in &amp;lt;module&amp;gt; api_response = client.crm.objects.notes.basic_api.create(simple_public_object_input_for_create=simple_public_object_input_for_create) File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api\basic_api.py", line 185, in create return self.create_with_http_info(simple_public_object_input_for_create, **kwargs) # noqa: E501 File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api\basic_api.py", line 266, in create_with_http_info return self.api_client.call_api( File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api_client.py", line 378, in call_api return self.__call_api( File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api_client.py", line 185, in __call_api response_data = self.request( File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api_client.py", line 428, in request return self.rest_client.POST(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\rest.py", line 207, in POST return self.request("POST", url, headers=headers, query_params=query_params, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\rest.py", line 143, in request r = self.pool_manager.request(method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) File "C:\userenv\lib\site-packages\urllib3\_request_methods.py", line 144, in request return self.request_encode_body( File "C:\userenv\lib\site-packages\urllib3\_request_methods.py", line 279, in request_encode_body return self.urlopen(method, url, **extra_kw) File "C:\userenv\lib\site-packages\urllib3\poolmanager.py", line 444, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 877, in urlopen return self.urlopen( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 877, in urlopen return self.urlopen( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 877, in urlopen return self.urlopen( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen retries = retries.increment( File "C:\userenv\lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/notes (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
Click here for troubleshooting help&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/usr/bin/env python3
import hubspot
from pprint import pprint
from hubspot import HubSpot
from hubspot.crm.objects.notes import SimplePublicObjectInputForCreate, ApiException

my_token = 'pat-na1-1489556d-xxxx-xxxx-xxxx-xxxxxxxxxx'

api_client = HubSpot()
api_client.access_token = my_token

properties = {
    "hs_note_body": "The note is copied from ADO work item using Automation Account",
    "hs_timestamp": "2024-02-27T03:30:17.883Z",
    "hubspot_owner_id": "xxxxxx" # ID of Hubspot user (using xxxx)
}
associations = [{
    "types":[{
        "associationCategory":"HUBSPOT_DEFINED",
        "associationTypeId":xxx # Hubpot associationType ID (Here is ID between note engagement &amp;amp; ticket object)
        }],
        "to":{
            "id":"xxxxxxx" # Hubspot ticket ID
        }
    }]
simple_public_object_input_for_create = SimplePublicObjectInputForCreate(associations=associations, properties=properties)
try:
    api_response = api_client.crm.objects.notes.basic_api.create(simple_public_object_input_for_create=simple_public_object_input_for_create)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling basic_api-&amp;gt;create: %s\n" % e)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 11:14:47 GMT</pubDate>
    <dc:creator>phuoctruong</dc:creator>
    <dc:date>2024-02-28T11:14:47Z</dc:date>
    <item>
      <title>Create workflow using customcode - python script</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/927946#M71362</link>
      <description>&lt;P&gt;I am developing a workflow using Dataops - customcode to add something from Hubspot ticket to Azure DevOps work item as a comment.&lt;/P&gt;&lt;P&gt;Here is my script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.devops.v7_1.py_pi_api import JsonPatchOperation
import pprint

# Fill in with your personal access token and org URL
personal_access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
organization_url = 'https://dev.azure.com/xxxxxxxxx'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = Connection(base_url=organization_url, creds=credentials)

# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.clients.get_core_client()

wit_client = connection.clients.get_work_item_tracking_client()

patch_document = [
    JsonPatchOperation(
        op="add",
        path="/fields/System.History",
        value={
            "text": "sample comment",
        },
    )
]

wit_client.update_work_item(patch_document, "xxxxx")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Python script works well locally but does not work on Hubspot workflow. Here is the error message&lt;/P&gt;&lt;PRE&gt;[ERROR] Runtime.ImportModuleError: Unable to import module 'hubspotHandler': No module named 'azure'&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am aware Hubspot dose not support the library named azure-devops right now so is there any way to import the module azure-devops?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In local machine, I use the command "pip install azure-devops"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 06:29:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/927946#M71362</guid>
      <dc:creator>phuoctruong</dc:creator>
      <dc:date>2024-02-23T06:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create workflow using customcode - python script</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/928268#M71364</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/715283"&gt;@phuoctruong&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you for reaching out to the community. The importing of other packages doesn't work, unfortunately, as you noticed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The documentation is pretty clear about what kind of packages you can use:&lt;/P&gt;
&lt;UL&gt;
&lt;LI data-stringify-indent="1" data-stringify-border="0"&gt;requests 2.28.2&lt;/LI&gt;
&lt;LI&gt;@hubspot/api-client ^8&lt;/LI&gt;
&lt;LI data-stringify-indent="1" data-stringify-border="0"&gt;google-api-python-client 2.74.0&lt;/LI&gt;
&lt;LI data-stringify-indent="1" data-stringify-border="0"&gt;mysql-connector-python 8.0.32&lt;/LI&gt;
&lt;LI data-stringify-indent="1" data-stringify-border="0"&gt;redis 4.4.2&lt;/LI&gt;
&lt;LI data-stringify-indent="1" data-stringify-border="0"&gt;nltk 3.8.1&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I'm not familiar with Azure, but this looks like a simple API call to me. You could also do this with the requests library, I think. Have you tried that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Christoph&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 14:31:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/928268#M71364</guid>
      <dc:creator>ChrisoKlepke</dc:creator>
      <dc:date>2024-02-23T14:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create workflow using customcode - python script</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/934342#M71496</link>
      <description>&lt;P&gt;Thank you for your rep,&lt;/P&gt;&lt;P&gt;I resolved the issue by using another service - Azure Automation Account, and I will Hubspot webhook instead of Hubspot customcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now, i have another script, the script will call to hubspot api and it works well locally but got SSL issue on Azure Automation Account.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Traceback (most recent call last): File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn conn.connect() File "C:\userenv\lib\site-packages\urllib3\connection.py", line 653, in connect sock_and_verified = _ssl_wrap_socket_and_match_hostname( File "C:\userenv\lib\site-packages\urllib3\connection.py", line 806, in _ssl_wrap_socket_and_match_hostname ssl_sock = ssl_wrap_socket( File "C:\userenv\lib\site-packages\urllib3\util\ssl_.py", line 465, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname) File "C:\userenv\lib\site-packages\urllib3\util\ssl_.py", line 509, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Python\lib\ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "C:\Python\lib\ssl.py", line 1040, in _create self.do_handshake() File "C:\Python\lib\ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen response = self._make_request( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/tmp/94079701-23ba-4aab-877d-d1b7f0ba2be3/runbooks/azuredevops.py", line 15, in &amp;lt;module&amp;gt; api_response = client.crm.objects.notes.basic_api.create(simple_public_object_input_for_create=simple_public_object_input_for_create) File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api\basic_api.py", line 185, in create return self.create_with_http_info(simple_public_object_input_for_create, **kwargs) # noqa: E501 File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api\basic_api.py", line 266, in create_with_http_info return self.api_client.call_api( File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api_client.py", line 378, in call_api return self.__call_api( File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api_client.py", line 185, in __call_api response_data = self.request( File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\api_client.py", line 428, in request return self.rest_client.POST(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\rest.py", line 207, in POST return self.request("POST", url, headers=headers, query_params=query_params, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) File "C:\userenv\lib\site-packages\hubspot\crm\objects\notes\rest.py", line 143, in request r = self.pool_manager.request(method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) File "C:\userenv\lib\site-packages\urllib3\_request_methods.py", line 144, in request return self.request_encode_body( File "C:\userenv\lib\site-packages\urllib3\_request_methods.py", line 279, in request_encode_body return self.urlopen(method, url, **extra_kw) File "C:\userenv\lib\site-packages\urllib3\poolmanager.py", line 444, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 877, in urlopen return self.urlopen( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 877, in urlopen return self.urlopen( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 877, in urlopen return self.urlopen( File "C:\userenv\lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen retries = retries.increment( File "C:\userenv\lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/notes (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
Click here for troubleshooting help&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/usr/bin/env python3
import hubspot
from pprint import pprint
from hubspot import HubSpot
from hubspot.crm.objects.notes import SimplePublicObjectInputForCreate, ApiException

my_token = 'pat-na1-1489556d-xxxx-xxxx-xxxx-xxxxxxxxxx'

api_client = HubSpot()
api_client.access_token = my_token

properties = {
    "hs_note_body": "The note is copied from ADO work item using Automation Account",
    "hs_timestamp": "2024-02-27T03:30:17.883Z",
    "hubspot_owner_id": "xxxxxx" # ID of Hubspot user (using xxxx)
}
associations = [{
    "types":[{
        "associationCategory":"HUBSPOT_DEFINED",
        "associationTypeId":xxx # Hubpot associationType ID (Here is ID between note engagement &amp;amp; ticket object)
        }],
        "to":{
            "id":"xxxxxxx" # Hubspot ticket ID
        }
    }]
simple_public_object_input_for_create = SimplePublicObjectInputForCreate(associations=associations, properties=properties)
try:
    api_response = api_client.crm.objects.notes.basic_api.create(simple_public_object_input_for_create=simple_public_object_input_for_create)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling basic_api-&amp;gt;create: %s\n" % e)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 11:14:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/934342#M71496</guid>
      <dc:creator>phuoctruong</dc:creator>
      <dc:date>2024-02-28T11:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create workflow using customcode - python script</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/935046#M71522</link>
      <description>&lt;P&gt;I fixed the above issue using python3.10 instead of 3.8&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 04:09:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Create-workflow-using-customcode-python-script/m-p/935046#M71522</guid>
      <dc:creator>phuoctruong</dc:creator>
      <dc:date>2024-02-29T04:09:32Z</dc:date>
    </item>
  </channel>
</rss>

