APIs & Integrations

Guich
Member

Issue with Template API

SOLVE

Hello, I'm getting an error message by the template API.
I'm using this one.

The PUT URL is: https://api.hubapi.com/content/api/v2/templates/7645641221

 

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

{
  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.

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

0 Upvotes
1 Accepted solution
Guich
Solution
Member

Issue with Template API

SOLVE

Ok, I found a solution.

Used the UTF8 NPM Package to force encoding of the string coming from the readFile.

View solution in original post

3 Replies 3
lscanlan
HubSpot Alumni
HubSpot Alumni

Issue with Template API

SOLVE

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

Leland Scanlan

HubSpot Developer Support
0 Upvotes
Guich
Member

Issue with Template API

SOLVE

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

 

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

For better readability:

{
    "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

0 Upvotes
Guich
Solution
Member

Issue with Template API

SOLVE

Ok, I found a solution.

Used the UTF8 NPM Package to force encoding of the string coming from the readFile.