# Custom angular form submission

**URL:** <https://community.hubspot.com/t/custom-angular-form-submission/79206>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [April 12, 2023, 7:45pm UTC](https://community.hubspot.com/t/custom-angular-form-submission/79206 "2023-04-12T19:45:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![01950](https://avatars.discourse-cdn.com/v4/letter/0/94ad74/32.png) [@01950](https://community.hubspot.com/u/01950)\
**Post date:** [April 12, 2023, 7:45pm UTC](https://community.hubspot.com/t/custom-angular-form-submission/79206/1 "2023-04-12T19:45:25Z")

</div>

Hello, I tried to use the embed code section into an angular 9 project but I did not work, so I created a custom form sending it to hubspot url [https://api.hsforms.com/submissions/v3/integration/submit/{{portalId}](https://api.hsforms.com/submissions/v3/integration/submit/%7B%7BportalId%7D)}/{{formId}}  
but it doesn’t create a ticket number automatically even if I have th option of creating it automatically on, I have all the required fields added to the form, an example of it the way I am using it in postman is this one:

{

“fields”: [

{

“name”: “firstname”,

“value”: “”

},

{

“name”: “lastname”,

“value”: “”

},

{

“name”: “email”,

“value”: “”

},

{

“name”: “TICKET.content”,

“value”: “”

},

{

“name”: “TICKET.feature\_request\_category”,

“value”: “Feature Request”

},

{

“name”: “TICKET.user\_role”,

“value”: “Role”

},

{

“name”: “attach\_file”,

“value”: “”

},

{

“name”: “TICKET.subject”,

“value”: “Feature Request Ticket (in-product)”

},

{

“name”: “TICKET.ticket\_type”,

“value”: “Feature Request”

}

]

}

Does anyone know what I am missing here?

---

<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:** [April 13, 2023, 8:11am UTC](https://community.hubspot.com/t/custom-angular-form-submission/79206/2 "2023-04-13T08:11:17Z")

</div>

Hello @01950

Forms API is designed to create contacts and not tickets.

To create a ticket in HubSpot, you can use the HubSpot Tickets API instead. Here’s an example of how you can submit a ticket to HubSpot using the Tickets API in Angular:

First, you’ll need to import the `HttpClient` module in your component:

```lia-code-sample
import { HttpClient, HttpHeaders } from '@angular/common/http';

```

Then, you can create a function to submit the ticket:

```lia-code-sample
submitTicket() {
 const headers = new HttpHeaders({
 'Content-Type': 'application/json'
 });

 const body = {
 subject: 'Feature Request Ticket (in-product)',
 content: 'Ticket content',
 hs_pipeline: '0',
 hs_pipeline_stage: '1',
 'requester.0.email': 'user@example.com',
 'requester.0.user_role': 'Role',
 'requester.0.ticket_type': 'Feature Request',
 'requester.0.feature_request_category': 'Feature Request'
 };

 this.http.post(`https://api.hubapi.com/crm-objects/v1/objects/tickets?hapikey=${yourApiKey}`, body, { headers }).subscribe(
 data => console.log(data),
 error => console.log(error)
 );
}

```

In this example, we’re using the `HttpClient` module to submit a POST request to the HubSpot Tickets API endpoint with the necessary parameters to create a new ticket.

Note that you’ll need to replace `yourApiKey` with your actual HubSpot API key.

Also, make sure to include the required fields in the `body` object. In this example, we’re including the ticket subject, content, pipeline stage, requester email, user role, ticket type, and feature request category.

---

<div class="post-metadata">

**Author:** ![seiscreativa](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@seiscreativa](https://community.hubspot.com/u/seiscreativa)\
**Post date:** [June 30, 2023, 2:57pm UTC](https://community.hubspot.com/t/custom-angular-form-submission/79206/3 "2023-06-30T14:57:13Z")

</div>

Hi,

May you help me with the example for Forms API to create contacts with Angular 15.

thanks!

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [April 26, 2023, 7:20am UTC](https://community.hubspot.com/t/custom-angular-form-submission/79206/4 "2023-04-26T07:20:29Z")

</div>

Hi @01950

It looks like you are trying to create a ticket in HubSpot using the HubSpot Forms API, but the ticket number is not being generated automatically.

HubSpot generates ticket numbers automatically only for tickets created through the Tickets API, not through the Forms API. Therefore, if you want the ticket number to be generated automatically, you should create the ticket using the Tickets API.

Here’s an example of how you could use the Tickets API to create a ticket in HubSpot:

1. First, you will need to obtain an OAuth access token from HubSpot.

2. Next, you can use the access token to make a POST request to the Tickets API endpoint, which is located at [https://api.hubapi.com/crm-objects/v1/objects/tickets](https://api.hubapi.com/crm-objects/v1/objects/tickets). The request body should include the following properties:

- `properties`: An object containing the properties of the ticket, including the `subject`, `content`, `ticket_type`, `feature_request_category`, and `user_role`.

- `associations`: An object containing the associations between the ticket and other HubSpot objects, such as contacts, companies, or deals. For example, you could associate the ticket with a contact by including the `contactIds` property and setting it to an array of contact IDs.

Here’s an example of what the request body might look like:

```  
{  
“properties”: {  
“subject”: “Feature Request Ticket (in-product)”,  
“content”: “This is the content of the ticket.”,  
“ticket\_type”: “Feature Request”,  
“feature\_request\_category”: “Feature Request”,  
“user\_role”: “Role”  
},  
“associations”: {  
“contactIds”: [123],  
“companyIds”: [456],  
“dealIds”: [789]  
}  
}  
```

3. Finally, you can parse the response to retrieve the ticket number, which is located in the `objectId` property of the response.

Note that you will need to have the appropriate permissions and access to use the Tickets API. Also, make sure that you are properly authenticating your requests using the access token.

Please mark it as SOLUTION ACCEPTED if you like the solution.

Thank you!
