APIs & Integrations

NicheDriven
Member

Can not create new ticket via API

SOLVE

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; 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\""], "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", { :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'} })

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Can not create new ticket via API

SOLVE

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 expects.

The final JSON should look like the following:

[
  {
    "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"
  }
]

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
3 Replies 3
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Can not create new ticket via API

SOLVE

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 expects.

The final JSON should look like the following:

[
  {
    "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"
  }
]

Isaac Takushi

Associate Certification Manager
0 Upvotes
NicheDriven
Member

Can not create new ticket via API

SOLVE

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

IsaacTakushi
HubSpot Employee
HubSpot Employee

Can not create new ticket via API

SOLVE

Thanks for sharing that tip, @NicheDriven!

Isaac Takushi

Associate Certification Manager
0 Upvotes