# API Exception Handling for custom Objects

**URL:** <https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [April 21, 2023, 9:15pm UTC](https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853 "2023-04-21T21:15:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JUrena](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JUrena](https://community.hubspot.com/u/JUrena)\
**Post date:** [April 21, 2023, 9:15pm UTC](https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853/1 "2023-04-21T21:15:24Z")

</div>

Im developing a Python script to import some custom objects and have just run into a non-issue, but rather a question. When creating a duplicate custom Object the HTTP return status is 400, but the same cannot be said when creating a duplicate Contact that scenario returns i believe 409. Just curious if this was by default or if im maybe missing something

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 24, 2023, 4:31pm UTC](https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853/2 "2023-04-24T16:31:55Z")

</div>

Hey, @JUrena 👋 Happy to investigate a bit more for us. To clarify, this is when you are creating a new, but duplicate, record on for your Custom Object? Not creating a new Custom Object itself? Meaning, if I have:

- a custom object called Cats
- I have an existing record called Tabby
- I try to create another record called Tabby
- I receive a 400 response instead of the expected 409 response

Or something similar? If not, that’s OK too. My goal is to make sure I understand 100% and not guess or assume.

Thanks! — Jaycee

---

<div class="post-metadata">

**Author:** ![JUrena](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JUrena](https://community.hubspot.com/u/JUrena)\
**Post date:** [April 24, 2023, 4:34pm UTC](https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853/3 "2023-04-24T16:34:45Z")

</div>

That is precisely the scenario I am encountering, thank you for making sure!

---

<div class="post-metadata">

**Author:** ![JUrena](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@JUrena](https://community.hubspot.com/u/JUrena)\
**Post date:** [April 24, 2023, 3:17pm UTC](https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853/4 "2023-04-24T15:17:45Z")

</div>

Im trying to use the python lib to make api calls but it seems like this

`api_client.crm.objects.basic_api.create`

end point doesnt return api exception 409 when there are duplicates like it does for contacts, it just returns 400. How can/should I be handling this scenario?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 24, 2023, 5:39pm UTC](https://community.hubspot.com/t/api-exception-handling-for-custom-objects/79853/5 "2023-04-24T17:39:06Z")

</div>

Merging with your other post to keep things neat 😊
