# Can not create new ticket via API

**URL:** <https://community.hubspot.com/t/can-not-create-new-ticket-via-api/17273>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [November 18, 2019, 8:27pm UTC](https://community.hubspot.com/t/can-not-create-new-ticket-via-api/17273 "2019-11-18T20:27:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicheDriven](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nichedriven/32/69256_2.png) [@NicheDriven](https://community.hubspot.com/u/NicheDriven)\
**Post date:** [November 18, 2019, 8:27pm UTC](https://community.hubspot.com/t/can-not-create-new-ticket-via-api/17273/1 "2019-11-18T20:27:28Z")

</div>

I am trying to post a new ticket using the API but I am getting the following error:

{“status”=\>“error”, “message”=\>“Cannot create object with type: 0-5. The following required properties were missing: [hs\_pipeline\_stage]”, “correlationId”=\>“a2a9b224-486f-477b-8217-6a1e1f0ce7f8”, “requestId”=\>“e6504956-b53b-4e96-bab2-0c4bc8c75492”}, @response=#\<Net::HTTPBadRequest 400 Bad Request readbody=true\>, @headers={“date”=\>[“Mon, 18 Nov 2019 17:28:03 GMT”], “content-type”=\>[“application/json;charset=utf-8”], “content-length”=\>[“241”], “connection”=\>[“close”], “set-cookie”=\>[“\_\_cfduid=dc83d4ba4944be0ea57eae6c7fa890b531574098083; expires=Tue, 17-Nov-20 17:28:03 GMT; path=/; [domain=.hubapi.com](http://domain=.hubapi.com); HttpOnly”], “x-trace”=\>[“2B23EF591939488C8A51F64F3CD7AAAD4EFE0EAF7A000000000000000000”], “vary”=\>[“Accept-Encoding”], “access-control-allow-credentials”=\>[“false”], “cf-cache-status”=\>[“DYNAMIC”], “strict-transport-security”=\>[“max-age=31536000; includeSubDomains; preload”], “expect-ct”=\>[“max-age=604800, report-uri=\”[[https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\\](https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct%5C%5C)]([https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\](https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct%5C))“”], “server”=\>[“cloudflare”], “cf-ray”=\>[“537ba8a08c15cf50-IAD”]}

Here is the code I am running:

response = HTTParty.post(“[https://api.hubapi.com/crm-objects/v1/objects/tickets?hapikey=REDACTED](https://api.hubapi.com/crm-objects/v1/objects/tickets?hapikey=REDACTED)”, { :body =\> [{ subject: “test ticket from Aaron”, content: “This is some content”, hs\_pipeline: “0”, hs\_pipeline\_stage: “1” }].to\_json, :headers =\> { ‘Content-Type’ =\> ‘application/json’, ‘Accept’ =\> ‘application/json’} })

---

<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:** [November 19, 2019, 9:33pm UTC](https://community.hubspot.com/t/can-not-create-new-ticket-via-api/17273/2 "2019-11-19T21:33:05Z")

</div>

Hi, @Tnichs.

Although you included valid `hs_pipeline` and `hs_pipeline_stage` values for your account, I’m guessing the JSON `to_json` spits out doesn’t match the format the [Tickets API](https://developers.hubspot.com/docs/methods/tickets/create-ticket) expects.  
The final JSON should look like the following:

```auto
[
 {
 "name": "subject",
 "value": "test ticket from Aaron"
 },
 {
 "name": "content",
 "value": "This is some content"
 },
 {
 "name": "hs_pipeline",
 "value": "0"
 },
 {
 "name": "hs_pipeline_stage",
 "value": "1"
 }
]

```

---

<div class="post-metadata">

**Author:** ![NicheDriven](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nichedriven/32/69256_2.png) [@NicheDriven](https://community.hubspot.com/u/NicheDriven)\
**Post date:** [November 19, 2019, 9:42pm UTC](https://community.hubspot.com/t/can-not-create-new-ticket-via-api/17273/3 "2019-11-19T21:42:05Z")

</div>

You are correct I was able to get it working by formatting it like this:

[{ “name”: “subject”, “value”: “This is an example ticket”}, {“name”: “content”, “value”: “Here are the details of the ticket.”}, {“name”: “hs\_pipeline”, “value”: “0”}, {“name”: “hs\_pipeline\_stage”, “value”: “1”}]

NOTE: Ruby devs… httparty didnt like this unless I passed it with a .to\_json

---

<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:** [November 20, 2019, 1:02pm UTC](https://community.hubspot.com/t/can-not-create-new-ticket-via-api/17273/4 "2019-11-20T13:02:44Z")

</div>

Thanks for sharing that tip, @NicheDriven!
