Thank you for your rep,
I resolved the issue by using another service - Azure Automation Account, and I will Hubspot webhook instead of Hubspot customcode.
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.
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 <module> 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
#!/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 & 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->create: %s\n" % e)