Hallo everyone, i am new to subspot. I want to POST my user contact details to Hubspot Private-App. So far i created Private-App and got ACCESS-CODE. Can anyone help me with Angular POST request code. this is my service code
import { HttpClient, HttpHeaders } from ‘@angular/common/http’;
import { Injectable } from ‘@angular/core’;
import { ApiService } from ‘ish-core/services/api/api.service’;
@Injectable({ providedIn: ‘root’ })
export class HubspotService {
private readonly accesstoken = my-access-token;
private readonly API_URL = ‘https://api.hubapi.com/’;
private readonly DEAL_URL = `${this.API_URL}deals/v1/deal?haccessTOKEN=${this.accesstoken}`;
constructor(private apiService: ApiService, private http: HttpClient) {}
private get headers() {
return new HttpHeaders({ 'Content-Type': 'application/json' });
}
saveContact(param: { firstname: string; lastname: string; email: string; tel: string }) {
console.log(param);
const url = this.DEAL\_URL;
const params = {
properties: \[
{
value: \`${param.firstname}\`,
name: 'firstname',
},
{
value: \`${param.lastname}\`,
name: 'lastname',
},
{
value: \`${param.email}\`,
name: 'email',
},
{
value: \`${param.tel}\`,
name: 'telnumber',
},
],
};
return this.http.post(url, params, { headers: this.headers });
}
getHubspot() {
return this.apiService.get('hubspot');
}
}