I’m using Zapier to create and publish quotes automatically via api calls. It’s all working pretty well, except that all of our quotes are defaulting to the wrong domain. When I create a new quote template it defaults to our blog.company.com domain, and I always change it to our invoice.company.com domain.
When I manually create or edit quotes they use the invoice.company.com domain but if I create and publish a quote strictly through api, it uses blog.company.com, until I go in and manually unpublish and republish it. Does anyone know why this happens or can anyone help me?
Here’s a boiled down version of the code I’m using. I added an extra step of changing the quote template in hopes that would help but it didn’t. I have also tried unpublishing and republishing the quote via api and that doesn’t help.
async function doStuff(){
theDate=Date.parse('10/20/2024')
console.log(theDate)
var url = 'https://api.hubapi.com/crm/v3/objects/quotes';
var data = {
properties: {
hs_title: 'Subscription Quote: test',
hs_expiration_date: theDate,
hs_status: "DRAFT",
hs_language: "en",
hs_sender_email: 'jeff@breatheforchange.com',
},
associations: [
{
to: {
id: 287996186925 // This should be replaced with the actual ID you want to associate with
},
types: [
{
associationCategory: "HUBSPOT_DEFINED",
associationTypeId: 286
}
]
}
]
};
var options = {
method: 'POST',
headers: {
'Authorization': `Bearer ${hapi-key}}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
};
var response=await fetch(url, options)
var responseData=await response.json()
var quoteId=responseData.properties.hs_object_id
console.log(responseData);
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/quote_template/285843884972`
options = {
method: 'PUT',
headers: {
'Authorization': `Bearer ${hapi-key}}`,
'Content-Type': 'application/json'
},
};
response=await fetch(url,options)
responseData=await response.json()
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/deals/16807831318`
response=await fetch(url,options)
responseData=await response.json()
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/line_items/7922834188`
response=await fetch(url,options)
responseData=await response.json()
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/contacts/4114597`
response=await fetch(url,options)
responseData=await response.json()
response = await fetch(
`https://api.hubapi.com/crm/v3/objects/quotes/${quoteId}`,
{
method: 'PATCH',
headers: {
'Authorization': `Bearer ${hapi-key}}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
properties: {
hs_status: "APPROVAL_NOT_NEEDED",
}
})
}
);
console.log('Response status:', response.status);
const text = await response.text();
console.log('Update expiration date response text:', text);
console.log(responseData);
url=`https://api.hubapi.com/crm/v3/objects/quotes/${quoteId}`
options = {
method: 'GET',
headers: {
'Authorization': `Bearer ${hapi-key}}`,
'Content-Type': 'application/json'
},
};
response=await fetch(url,options)
responseData=await response.json()
console.log(responseData);
}
doStuff();