can i set custo header per each request?

I want to set custom headers per each request.

for example, i want to traceId for request

const hubspotClient = new Client({ accessToken: 'accessToken' });

hubspotClient.crm.deals.basicApi.getById(dealId, { headers: { 'x-request-id': uuId() } })​

can i do this for now? or there is no function for this..?

Hi @arthurHwang,

Yes, you can set custom headers for each request when using the HubSpot API. However, I don’t think the official HubSpot API client does not directly support custom headers in the way you specified in your example. To achieve this, you will need to use an HTTP client such as axios, fetch, or a similar library.

Here’s an example using axios to add a custom header to your request:

const axios = require(‘axios’); const hubspotClient = axios.create({ baseURL: ‘https://api.hubapi.com’, headers: { ‘Authorization’: `Bearer ${accessToken}` } }); const traceId = uuId(); // Generate your UUID here const dealId = ‘your_deal_id’; hubspotClient.get(`/crm/v3/objects/deals/${dealId}`, { headers: { ‘x-request-id’: traceId } }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error); });

In this example:

  • axios.create is used to create a pre-configured instance of axios with the base URL and authorization header.
  • When making the request, you add the custom header x-request-id using the headers option in the request configuration.

If you prefer to stick with the HubSpot API client, you might consider making a feature request to HubSpot support or checking their documentation for any updates regarding this functionality.
Please give me a shout if you have any questions.
Cheers,
James - CEO @ Portant

Automate Hubspot to Google Docs with the Portant App:
https://ecosystem.hubspot.com/marketplace/apps/sales/sales-enablement/portant-hubspot-google-docs-in…

thank you for answer! I was just wondering about custom header set with SDK :slightly_smiling_face:

No problem @arthurHwang. Glad to help.