APIs & Integrations

SM6
Miembro

API - Creating a New Deal

resolver

Hello,

 

I am trying to use the HubSpot API to create a new deal associated with an existing contact and with a specified dealname, dealstage, and amount.

 

This is the code that I am using:

 

HAPI_KEY = 'XXXXXXXXXX'
client = hubspot.Client.create(api_key = HAPI_KEY)

hs_owner_id = 'XXXXXXXXXX'
properties = {
    "amount": 'XXXX',
    "dealname": 'XXXX',
    "dealstage": 'XXXX',
    "hubspot_owner_id": hs_owner_id,
    "pipeline": "default"
}

simple_public_object_input = SimplePublicObjectInput(properties=properties)
try:
    api_response = client.crm.deals.basic_api.create(simple_public_object_input=simple_public_object_input)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling basic_api->create: %s\n" % e)

 

 

This is what is printed out:

 

Exception when calling basic_api->create: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict(...)
HTTP response body: {"status":"error","message":"Property values were not valid: [{\"isValid\":false,\"message\":\"XXXXXX was not a valid owner ID\",\"error\":\"INVALID_OWNER_ID\",\"name\":\"hubspot_owner_id\"}]","correlationId":"XXXXXXX","category":"VALIDATION_ERROR"}

 

 

However, I have checked, using both HubSpot's website and the API, that the contact does in fact exist and that the contact ID is valid. Does anyone know why this is happening and how a new deal should be created? Thank you in advance!

0 Me gusta
1 Soluciones aceptada
tominal
Solución
Guía | Partner
Guía | Partner

API - Creating a New Deal

resolver

You may be confusing the HubSpot Owner IDs with Contact IDs. Owner IDs are the users that can log in to your HubSpot portal and can be found using the Owners API. https://developers.hubspot.com/docs/api/crm/owners 

I hope this helps!


Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com

Ver la solución en mensaje original publicado

1 Respuesta 1
tominal
Solución
Guía | Partner
Guía | Partner

API - Creating a New Deal

resolver

You may be confusing the HubSpot Owner IDs with Contact IDs. Owner IDs are the users that can log in to your HubSpot portal and can be found using the Owners API. https://developers.hubspot.com/docs/api/crm/owners 

I hope this helps!


Thomas Johnson
Community Champion


Kahu Software LLC
A Texan HubSpot consulting firm
https://kahusoftware.com