# API error on creating Ticket

**URL:** <https://community.hubspot.com/t/api-error-on-creating-ticket/47736>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [November 30, 2021, 2:49pm UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736 "2021-11-30T14:49:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDijkstra](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@SDijkstra](https://community.hubspot.com/u/SDijkstra)\
**Post date:** [November 30, 2021, 2:49pm UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/1 "2021-11-30T14:49:26Z")

</div>

Hi,

I am using the PHP API and I am trying to create a new ticket with the API, but I am getting the following error.

Exception when calling basic\_api-\>create: [400] Client error: `POST [https://api.hubapi.com/crm/v3/objects/tickets?hapikey=XXX\`](https://api.hubapi.com/crm/v3/objects/tickets?hapikey=XXX%5C%60) resulted in a `400 Bad Request` response: {“status”:“error”,“message”:“Error creating TICKET. Some required properties were not set.”,“correlationId”:"a0136598-f (truncated…)

I am using the documentation:

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fapi-reference%2Fcrm-tickets-v3%2Fguide)**

I remove the API-key, but the API connection is valid, but I am getting the error above when I am trying to add a ticket.

I am trying to use this properties:

$properties = [  
“hs\_pipeline” =\> “support\_pipeline”,  
“hs\_pipeline\_stage” =\> “open”,  
“hs\_ticket\_priority” =\> “HIGH”,  
“hubspot\_owner\_id” =\> “”,  
“subject” =\> “Example Ticket”,  
“content” =\> “I am creating a new ticket”  
];  
$SimplePublicObjectInput = new SimplePublicObjectInput([‘properties’ =\> $properties]);

Is there somethin I am missing, because I’ve copy pasted the code from the documentation but still getting an error.

Hope somebody van help me, thanks in advance!

---

<div class="post-metadata">

**Author:** ![TitiCuisset](https://avatars.discourse-cdn.com/v4/letter/t/8baadc/32.png) [@TitiCuisset](https://community.hubspot.com/u/TitiCuisset)\
**Post date:** [December 1, 2021, 11:12am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/2 "2021-12-01T11:12:23Z")

</div>

Hi @SDijkstra

Thank you for reaching out.

I want to tag some of our experts on this - @himanshurauthan @miljkovicmisa do you know what could be happening here?

Thank you!

Best

Tiphaine

---

<div class="post-metadata">

**Author:** ![theferrett](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@theferrett](https://community.hubspot.com/u/theferrett)\
**Post date:** [May 17, 2022, 9:13pm UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/3 "2022-05-17T21:13:47Z")

</div>

The answers given above are incorrect. The problem is that the SDK’s sanitization routine is bugged so it’s stripping the request of all its POST fields before it sends the create request, meaning the SDK cannot be used to create a ticket at this time.

I’ve posted an issue to their GitHub; we’ll see if they can fix it soon.

---

<div class="post-metadata">

**Author:** ![FRenteria](https://avatars.discourse-cdn.com/v4/letter/f/41988e/32.png) [@FRenteria](https://community.hubspot.com/u/FRenteria)\
**Post date:** [February 1, 2023, 7:07pm UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/4 "2023-02-01T19:07:51Z")

</div>

Hi!  
I woudl like to know if you were able to solve this issue..

I’m having the same problem and I haven’t the solution.

Could you help me with this? I will appreciate it.

Thanks

---

<div class="post-metadata">

**Author:** ![SDijkstra](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@SDijkstra](https://community.hubspot.com/u/SDijkstra)\
**Post date:** [December 2, 2021, 7:50am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/5 "2021-12-02T07:50:38Z")

</div>

Hi TiphaineCuisset,

Thanks for that! I can add some additional information, which I am seeing in the Hubspot account.

HEADER:

User-Agent: hubspot-api-client-php; 4.0.0  
CDN-Loop: cloudflare; subreqs=1  
Accept-Encoding: gzip  
CF-Connecting-IP: 2a03:9700:8000:0:eea5:488:e1b0:3e89  
True-Client-IP: 2a03:9700:8000:0:eea5:488:e1b0:3e89  
X-HubSpot-Trace: 32d4e945fa005303f90bab821fe430bc  
X-HubSpot-Correlation-Id: f3c497e6-f545-42ae-b143-0f665a97fa7b  
X-HS-Internal-Request: 1  
Content-Length: 2  
X-Real-IP: 2a03:9700:8000:0:eea5:488:e1b0:3e89  
Content-Type: application/json  
cf-worker: [hubapi.com](http://hubapi.com)  
CF-IPCountry: NL  
CF-RAY: 6b65160a543e1e9d-EWR  
Accept: application/json  
X-Forwarded-Proto: https  
Connection: close  
X-Request-Start: 1638285902.527  
X-HS-Internal-User-Request: 0  
Host: [api.hubapi.com](http://api.hubapi.com)  
CF-Visitor: {"scheme":"https"}  
X-HS-User-Request: 0  
CF-EW-Via: 15  
X-Forwarded-Port: 443  
X-Amzn-Trace-Id: Root=1-61a6424e-3c36ab055f89bb9d53299ecf  
X-Forwarded-For: 2a03:9700:8000:0:eea5:488:e1b0:3e89, 172.70.114.52, 2a03:9700:8000:0:eea5:488:e1b0:3e89  
X-Scheme: https

X-HubSpot-RateLimit-Remaining: 96  
X-HubSpot-RateLimit-Max: 100  
X-HubSpot-RateLimit-Daily: 250000  
X-HubSpot-RateLimit-Daily-Remaining: 249903  
X-HubSpot-RateLimit-Interval-Milliseconds: 10000  
X-HubSpot-RateLimit-Secondly: 10  
X-HubSpot-RateLimit-Secondly-Remaining: 9  
Content-Type: {"type":"application","subtype":"json","parameters":{"charset":"UTF-8"},"wildcardType":false,"wildcardSubtype":false}

TEXT:

{  
“status”: “error”,  
“message”: “Error creating TICKET. Some required properties were not set.”,  
“correlationId”: “f3c497e6-f545-42ae-b143-0f665a97fa7b”,  
“context”: {  
“properties”: [  
“hs\_pipeline\_stage”  
]  
},  
“category”: “VALIDATION\_ERROR”  
}

RESPONSE:

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [December 2, 2021, 8:54am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/6 "2021-12-02T08:54:16Z")

</div>

Hi @SDijkstra ,

When I tried it with Postman I’ve an error that the hs\_pipeline\_stage is not valid.

I changed the payload a bit, and now it’s working for me:

```lia-code-sample
$properties = [
 "hs_pipeline" => "0",
 "hs_pipeline_stage" => "1",
 "hs_ticket_priority" => "HIGH",
 "hubspot_owner_id" => "",
 "subject" => "Example Ticket",
 "content" => "I am creating a new ticket" 
];

```

I tink Hubspot is expecting a pipeline ID and and Pipeline Stage ID

Regards Ronald

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [December 7, 2021, 7:45am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/7 "2021-12-07T07:45:06Z")

</div>

Hello @SDijkstra,

I have checked and found that the properties values that you are sending are not correct. Please send the id of the pipeline and pipeline stage instead name.

```lia-code-sample
$properties = [

 "hs_pipeline" => "0",

 "hs_pipeline_stage" => "1",

 "hs_ticket_priority" => "HIGH",

 "hubspot_owner_id" => "",

 "subject" => "Example Ticket",

 "content" => "I am creating a new ticket"

];

```

I have tested with the above array and got the 201 success code.

Regards,

---

<div class="post-metadata">

**Author:** ![SDijkstra](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@SDijkstra](https://community.hubspot.com/u/SDijkstra)\
**Post date:** [December 7, 2021, 8:04am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/8 "2021-12-07T08:04:25Z")

</div>

Hi both,

Thanks voor your replies, a colleague of mine is working on it further. I will pass on your tips!

---

<div class="post-metadata">

**Author:** ![DdeGraaf](https://avatars.discourse-cdn.com/v4/letter/d/4bbf92/32.png) [@DdeGraaf](https://community.hubspot.com/u/DdeGraaf)\
**Post date:** [December 7, 2021, 9:07am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/9 "2021-12-07T09:07:43Z")

</div>

Thanks @himanshurauthan & @RMones !  
I have implemented all parameters to the following result:

> <https://pastebin.com/Ti2TAt0W>

Nevertheless the error doesn’t change.

When I look at the received request somehow the body seems empty, I tried using the api docs interface with our API and that does create the body. Can dependencies/phpversions etc. be blocking the actual sending of the content body?

 ![lfCoCd3.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/8/88d01f7e4c9a6ee1735ff2a3797a853d48ce3fda.png)

VS

 ![lfCoCd3.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/8/88d01f7e4c9a6ee1735ff2a3797a853d48ce3fda.png)

 ![FLXRD6w1.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/0/b079f7c7cef0ae2c3acd27297f0392dff6730a00.png)

Hoping to get some insights, will try and send a clean CURL with all the parameters as well to verify this might be the issue.

---

<div class="post-metadata">

**Author:** ![DdeGraaf](https://avatars.discourse-cdn.com/v4/letter/d/4bbf92/32.png) [@DdeGraaf](https://community.hubspot.com/u/DdeGraaf)\
**Post date:** [December 7, 2021, 9:31am UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/10 "2021-12-07T09:31:29Z")

</div>

I just tried a plain CURL request with the same full body and it fires correctly and creates the ticket.

Something in the library/dependencies/configuration/versioning seems to be creating the empty body.  
Since both me and my collegue have the same exact issue would suggest there is a broader problem than just a single configuration right? We have tried it from atleast 3 machines and a server. All same issue.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [December 20, 2021, 2:22pm UTC](https://community.hubspot.com/t/api-error-on-creating-ticket/47736/11 "2021-12-20T14:22:08Z")

</div>

Hello @SDijkstra,

I tried using the API docs interface and ticket created on my portal and I used the following parameter:

```lia-code-sample
$properties = [

 "hs_pipeline" => "0",

 "hs_pipeline_stage" => "1",

 "hs_ticket_priority" => "HIGH",

 "hubspot_owner_id" => "",

 "subject" => "Example Ticket",

 "content" => "I am creating a new ticket"

];

```

I changed the **hs\_pipeline code** instead of the **hs\_pipeline** name.

Please change the hs\_pipeline and hs\_pipeline\_stage with their codes instead of their name.

Regards,
