Skip to content

Custom Code ERROR with a private API #23

@C-LineM

Description

@C-LineM

Hello, i have so many errors with my custom code to connect a dialer tool (Diabolocom) and i don't understand why : Could you please help me ?

import os

from hubspot import HubSpot

from hubspot.crm.contacts import ApiException

import requests

import json

import re

def main(event):

JN_HUBSPOT_API_KEY = "MY_KEY"

hubspot = HubSpot(api_key=JN_HUBSPOT_API_KEY)

try:

ApiResponse = hubspot.crm.contacts.basic_api.get_by_id('contact_id')

phone=ApiResponse.properties.get('phone')

phone = re.sub("^0(.*)",r"33\1",phone)
phone=phone.replace(" ","")

hs_object_id=ApiResponse.properties.get('hs_object_id')

except ApiException as e:

    print(e)

    raise

diabolocom_api_endpoint = "URL"

headers = {

'Private-Token': TOKEN_DIABOLO',

'Content-Type': 'application/json'

}

payload = json.dumps({

"priority": 10,
  
"customFields": {

"phone": phone,
"nom": lastname,
"prenom": firstname,
"fp_campagne": fp___campagne,
"id_contact": id_contact
}

})

r=requests.post(diabolocom_api_endpoint, headers=headers, data=payload)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions