Hi, we have a back-end suitelet that returns a JSO...
# suitescript
w
Hi, we have a back-end suitelet that returns a JSON in the body of the response. In some cases when contacting the suitelet with nlapiRequestURL, netsuite appends the diagnostic data to the end of the body. "<!-- 103 s: 68% #52 cache: 0% #1 --> <!-- Host [ a10.prod.ams ] App Version [ 2020.1.0.107 ] --> <!-- COMPID [ XXXX] EMAIL [XXXX@YYY.com ] URL [ /app/site/hosting/scriptlet.nl ] Time [ Mon Aug 03 025412 PDT 2020 ] --> <!-- Not logging slowest SQL -->" Does anyone know why it adds this in some cases but not all? (the client script fails in the current setup as it cannot JSON.parse() it with that in the end)
n
Hmm, I have seen this too and cannot for the life of me recall what caused it. Hoping someone else knows for sure but I have a feeling this is related to content-type and something to do with jsonp, maybe someone will read this and it'll spark a response.
w
Thank you for the reply. The one were the tags are included has the content-type text/html while the other has text/plain. I don't think we set those explicitly in the suitelet. Might have something to do with the length. My sample that has the tags is 36335 chars long (incl. tags) and the one without is 27445. Will look into that.
Added a line to set the content-type explicitly in the suitelet response to 'JSON' and that solved it. Thanks @NElliott.
Apparently when the text either contains a "<" or a ">" anywhere in the text, Netsuite sets the content-type to text/html and adds the host-data automatically. Might be other chars as well, but those are the ones that I tested with.