# Can't create deal using Deals API

**URL:** <https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413>\
**Category:** APIs & Integrations\
**Tags:** object\
**Created:** [October 22, 2018, 9:50pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413 "2018-10-22T21:50:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Leduc](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexandre_leduc/32/101739_2.png) [@Alexandre\_Leduc](https://community.hubspot.com/u/Alexandre_Leduc)\
**Post date:** [October 22, 2018, 9:50pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/1 "2018-10-22T21:50:47Z")

</div>

Hello,

I’m using R to create deals through the Deals API. Here’s a basic example of what I’m sending (Ignore R syntax, I’ve broken it out to make it easier to follow):

```auto
body<-
 {
 "properties": [
 {
 "value": "Testing",
 "name": "dealname"
 },
 {
 "value": "appointmentscheduled",
 "name": "dealstage"
 }
 ]
} 
POST(paste("https://api.hubapi.com/deals/v1/deal?hapikey={my_apikey}),body)

```

I get a 200 response but don’t see anything in Deals when I open Hubspot. My APP has Basic OAuth functionality and Contacts checked (I couldn’t find a section that specifically was for Deals, so I’m assuming Contacts is correct). As an aside, I’m able to edit contacts with this API key so I know it connects.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 23, 2018, 2:02pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/2 "2018-10-23T14:02:24Z")

</div>

Hi [@Alexandre\_Leduc](https://community.hubspot.com/u/alexandre_leduc),

Happy to help. The endpoint should return JSON-formatted data for the newly-created deal:

```auto
{
 "portalId": 62515,
 "dealId": 123456,
 "isDeleted": false,
 "associations": {
 "associatedVids": [
 9876
 ]
...
}

```

Could you share examples of those responses? Please be sure to include your Hub ID (`portalId`) as well.

---

<div class="post-metadata">

**Author:** ![Alexandre\_Leduc](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexandre_leduc/32/101739_2.png) [@Alexandre\_Leduc](https://community.hubspot.com/u/Alexandre_Leduc)\
**Post date:** [October 23, 2018, 3:17pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/3 "2018-10-23T15:17:16Z")

</div>

Hi Isaac,

Is the return necessary to create the deal? I just focused on the POST and I’ve just been looking to HubSpot for the deal created within the actual Deals screen. My portal ID is 4669976

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 23, 2018, 3:36pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/4 "2018-10-23T15:36:08Z")

</div>

Hi [@Alexandre\_Leduc](https://community.hubspot.com/u/alexandre_leduc),

No, you’ll only get a return if a deal is created. With the `dealId`, I should be able to locate the record or at least find out what happened to it.

---

<div class="post-metadata">

**Author:** ![Alexandre\_Leduc](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexandre_leduc/32/101739_2.png) [@Alexandre\_Leduc](https://community.hubspot.com/u/Alexandre_Leduc)\
**Post date:** [October 23, 2018, 5:02pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/5 "2018-10-23T17:02:40Z")

</div>

Hi Isaac, I don’t actually seem to be getting any response text..just a status 200? I tested my other script where I update contact info and it’s also not returning any response though?

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 23, 2018, 7:04pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/6 "2018-10-23T19:04:27Z")

</div>

Hi [@Alexandre\_Leduc](https://community.hubspot.com/u/alexandre_leduc),

Are you including the `content-type` header? I wonder if you’re erroneously getting a `200` response due to this behavior:

![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/0/102ea28e92c9be565c9b7d3a70c8f9a86d671e18.png) [Deal creation API - response is 200, but the deal is not created](https://integrate.hubspot.com/t/deal-creation-api-response-is-200-but-the-deal-is-not-created/9157/5) [Deals](https://community.hubspot.com/c/deals)

> Yes, the only difference between a working request and a failing request was the content-type header. Requests to Contacts API work fine also without the content-type header. For example the following works fine: r1 = requests.post(‘[https://api.hubapi.com/contacts/v1/contact/?hapikey=](https://api.hubapi.com/contacts/v1/contact/?hapikey=)’ + apiKey, data=json.dumps(contact)) Bests

---

<div class="post-metadata">

**Author:** ![Alexandre\_Leduc](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexandre_leduc/32/101739_2.png) [@Alexandre\_Leduc](https://community.hubspot.com/u/Alexandre_Leduc)\
**Post date:** [October 23, 2018, 8:26pm UTC](https://community.hubspot.com/t/cant-create-deal-using-deals-api/11413/7 "2018-10-23T20:26:44Z")

</div>

Thanks Isaac! That was exactly my problem. For anyone else using R, here’s the correct syntax to get this to work:  
`POST(paste("https://api.hubapi.com/deals/v1/deal?hapikey=",apikey,sep=""),body = body_json, content_type('application/json'))`  
-Note: Body\_json is my JSON output that I included above
