APIs & Integrations

AJD
Member

Using COS API to update an email template

I am using the COS API “Update the Template” (PUT /content/api/v2/templates/:template_id) to add additional content to a template, but the operation fails with “The remote server returned an error: (405) Method Not Allowed.”

The endpoint being used is http://api.hubapi.com/content/api/v2/templates/1...5?hapikey=… (where the template Id and API key are correct values). The request body is JSON data with just the id, label and source values.

Should this operation work? If so, why is it failing?

0 Upvotes
2 Replies 2
Dadams
HubSpot Employee
HubSpot Employee

Using COS API to update an email template

Hi @AJD

Sounds like you’re using the endpoint here?

Update the Template | COS Templates

PUT /content/api/v2/templates/:template_id - Updates the Template in the database. If not all the fields are included in the body, we will only update the included fields.

That endpoint should work with a PUT request, and I’m not seeing any issues testing that on my side.

Can you share any other details for the request? Even if there was a problem with the data, I wouldn’t expect a 405 response from that endpoint unless you were making some type of request other than PUT, GET, or DELETE.

0 Upvotes
AJD
Member

Using COS API to update an email template

I was using a method I had originally developed for the Forms API to POST data to Hubspot to send the updated template to the COS API endpoint. I have now created a new HTTP PUT method - using the same endpoint and JSON data now correctly updates the template.

0 Upvotes