<?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 API - Creating a New Deal in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/API-Creating-a-New-Deal/m-p/576936#M50923</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code that I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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-&amp;gt;create: %s\n" % e)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is printed out:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Exception when calling basic_api-&amp;gt;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"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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!&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 01:46:19 GMT</pubDate>
    <dc:creator>SM6</dc:creator>
    <dc:date>2022-02-16T01:46:19Z</dc:date>
    <item>
      <title>API - Creating a New Deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Creating-a-New-Deal/m-p/576936#M50923</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code that I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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-&amp;gt;create: %s\n" % e)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is printed out:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Exception when calling basic_api-&amp;gt;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"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 01:46:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Creating-a-New-Deal/m-p/576936#M50923</guid>
      <dc:creator>SM6</dc:creator>
      <dc:date>2022-02-16T01:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: API - Creating a New Deal</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/API-Creating-a-New-Deal/m-p/576945#M50924</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/api/crm/owners" target="_blank"&gt;https://developers.hubspot.com/docs/api/crm/owners&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 02:51:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/API-Creating-a-New-Deal/m-p/576945#M50924</guid>
      <dc:creator>tominal</dc:creator>
      <dc:date>2022-02-16T02:51:02Z</dc:date>
    </item>
  </channel>
</rss>

