# Issue with Template API

**URL:** <https://community.hubspot.com/t/issue-with-template-api/14165>\
**Category:** APIs & Integrations\
**Tags:** cms-content, developer-tools, timeline-and-extensions-apis\
**Created:** [April 30, 2019, 10:46am UTC](https://community.hubspot.com/t/issue-with-template-api/14165 "2019-04-30T10:46:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guich](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/guich/32/81309_2.png) [@Guich](https://community.hubspot.com/u/Guich)\
**Post date:** [April 30, 2019, 10:46am UTC](https://community.hubspot.com/t/issue-with-template-api/14165/1 "2019-04-30T10:46:55Z")

</div>

Hello, I’m getting an error message by the template API.  
I’m using [this one](https://developers.hubspot.com/docs/methods/templates/put_templates_template_id).  
The PUT URL is: [https://api.hubapi.com/content/api/v2/templates/7645641221](https://api.hubapi.com/content/api/v2/templates/7645641221)

This is an example of the error I’m getting.

```auto
{
 correlationId: "db3a660d-5d18-417f-97bd-f032ea2bb676"
 message: "Invalid UTF-8 start byte 0xf9↵ at [Source: java.io.SequenceInputStream@18302afa; line: 1, column: 22146]"
 requestId: "85492b7cd2affd886e25c3a783babbc8"
 status: "error"
}

```

The code I’m trying to push is a JS built with Webpack.  
It’s the first time since some month that I’m gettin this.  
A sample of the code I’m trying to upload is in this [pastebin](https://pastebin.com/2sC25YGy).  
Any help would be so appreciated.  
Thank u  
Update:  
If I copy/paste the code of the pastebin into the DM and then save, it works fine…  
So, I think, there is something wrong with the API

---

<div class="post-metadata">

**Author:** ![lscanlan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lscanlan/32/66262_2.png) [@lscanlan](https://community.hubspot.com/u/lscanlan)\
**Post date:** [May 1, 2019, 3:17pm UTC](https://community.hubspot.com/t/issue-with-template-api/14165/2 "2019-05-01T15:17:34Z")

</div>

Hi @Guich,

Does this happen for you every time you try to make this request? I was able to pass this JavaScript through the Templates API just now. I escaped the string before passing the request, and then used just Postman to make my request.

Could you provide some more details about how you’re making the request? I wonder if there’s something about your setup that’s causing that error. It sounds like our API is encountering a character that isn’t valid UTF-8.

- Leland

---

<div class="post-metadata">

**Author:** ![Guich](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/guich/32/81309_2.png) [@Guich](https://community.hubspot.com/u/Guich)\
**Post date:** [May 2, 2019, 7:24am UTC](https://community.hubspot.com/t/issue-with-template-api/14165/3 "2019-05-02T07:24:02Z")

</div>

Hi @lscanlan,  
thanks for the reply.  
This is the code for the upload of the file:

 ![Schermata 2019-05-02 alle 09.21.00.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/d/1de029672dcbd532ba321489f5289994ddbc4a4e.png)

I’m using node.js with request-promise.  
I push online also some css files with the same code and no issue at all.  
Anyway, I’ve tried to escape the code and push with Postman, but I’m getting and error too also here.  
The error is:

 ![Schermata 2019-05-02 alle 09.23.12.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/c/4c362016940126ead8d06c1630e8d5a206989804.png)

For better readability:

```auto
{
 "status": "error",
 "message": "Unexpected character ('!' (code 33)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: java.io.SequenceInputStream@685cc824; line: 1, column: 2]",
 "correlationId": "475591be-0449-416b-a2f3-b85ce16b19ab",
 "requestId": "77dc2b829c8615b438db84ce78c13ff6"
}

```

Thanks for the support.  
Guido

---

<div class="post-metadata">

**Author:** ![Guich](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/guich/32/81309_2.png) [@Guich](https://community.hubspot.com/u/Guich)\
**Post date:** [May 6, 2019, 10:45am UTC](https://community.hubspot.com/t/issue-with-template-api/14165/4 "2019-05-06T10:45:48Z")

</div>

Ok, I found a solution.  
Used the [UTF8 NPM Package](https://www.npmjs.com/package/utf8) to force encoding of the string coming from the readFile.
