Suitelet https.serverResponse is adding HTML comme...
# suitescript
g
Suitelet https.serverResponse is adding HTML comments at end of JSON. Has anyone seen this before? How to remove these comments from the response? In the suitelet I am simply doing:
Copy code
response.write(JSON.stringify(object))
b
set the correct content type header
g
I am trying to use application/json but I'm getting the same result
b
what does the code look like
g
Simply returning a search in a JSON format
b
i wont be able to help you if i cant reproduce the problem
g
I believe it's not related to the code, because I've used the same code in a different account in the past and it worked fine. One thing that is different at this time is that NetSuite adds a Cookie on the request: NS_ROUTING_VERSION=LAGGING
b
you get the logging comment when netsuite thinks your content contains html
g
I am doing response.write(JSON.stringify(object))
b
whatever object you are writing has html in it
or something that looks like html to netsuite
you would not get the logging comment if you did something like
Copy code
response.write('{}')
g
Wow, that's exactly that, I removed all the columns from the search but one and the HTML tags didn't appear anymore. Thank you!
b
the normal fix is to set the content type header in the response
g
not sure why it didn't work, there was nothing special on the JSON file
Would you know any workarounds @battk? I found the field that is returning the error. It's the display name of the item record, which can have many special characters and can be very long.
I found the issue, some items have ">" or "<" on the display name. I am having a hard time now to remove it in the saved search. It seems it doesn't recognize these characters when I use replace or translate, even if I use the ASCII code (e.g. ">" = CHR(62) )
b
i wont be able to help you if i cant reproduce the problem
t
@Gustavo Doná Adding this should help:
response.setHeader( 'Content-Type', 'application/json' );
👍 1
103 Views