# HTTP ERROR 415 when creating ticket via api.

**URL:** <https://community.hubspot.com/t/http-error-415-when-creating-ticket-via-api/20800>\
**Category:** APIs & Integrations\
**Tags:** timeline-and-extensions-apis\
**Created:** [May 12, 2020, 4:32pm UTC](https://community.hubspot.com/t/http-error-415-when-creating-ticket-via-api/20800 "2020-05-12T16:32:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AjaySR](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ajaysr/32/74736_2.png) [@AjaySR](https://community.hubspot.com/u/AjaySR)\
**Post date:** [May 12, 2020, 4:32pm UTC](https://community.hubspot.com/t/http-error-415-when-creating-ticket-via-api/20800/1 "2020-05-12T16:32:07Z")

</div>

I am creating a ticket via new api and I keep recieving this error.

`Problem accessing /crm/v3/objects/tickets. Reason: Unsupported Media Type`

Here is my JSON String:

```auto
$data_JSON = "{
 'properties':
 {
 'hs_pipeline': '2081686',
 'hs_pipeline_stage' : '2081687',
 'hs_ticket_category': 'PRODUCT_ISSUE',
 'content': 'This is a test is product issue ticket done.'
 }
 }";

```

And here is the POST call for creating the ticket:

```auto
function creatTicket($token)
{
 $curl = curl_init('https://api.hubapi.com/crm/v3/objects/tickets');
 curl_setopt($curl, CURLOPT_POST, true);
 curl_setopt($curl, CURLOPT_POSTFIELDS, $data_JSON);
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_HEADER, true);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
 "Accept:application/json",
 "Content-Type:application/json",
 "Authorization: Bearer ".$token,
 ));
 $response = curl_exec($curl);
 curl_close($curl);
 return $response;
}

```

Some help is really appriciated  
 ![16x16_smiley-happy.png.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/2/22d5e40d253def47f5f4ea7f0e3e70be19010689.png)  
.

---

<div class="post-metadata">

**Author:** ![AjaySR](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ajaysr/32/74736_2.png) [@AjaySR](https://community.hubspot.com/u/AjaySR)\
**Post date:** [May 12, 2020, 10:58pm UTC](https://community.hubspot.com/t/http-error-415-when-creating-ticket-via-api/20800/2 "2020-05-12T22:58:15Z")

</div>

I realized the mistake. I am just adding the wrong variable in

`curl_setopt($ch, CURLOPT_HEADER, true);`

It should be:

` curl_setopt($curl, CURLOPT_HEADER, true);`
