JSSPs not returning proper character encoding

This article explains how to resolve the issue in Campaign Classic where JSSPs are not returning proper character encoding within the header ContentTypeif it hasn’t been properly defined.

Description description

Environment

Adobe Campaign Classic

Issue/Symptoms

Sometimes within the header ContentTypean error is thrown as it has not been properly defined. When using JSSPs, the content type is not returning application/json; charset=utf-8.

Resolution resolution

To fix this, add ContentTypein JavaScript before the rest of the code is executed.

<%
response.setContentType("text/html;charset=utf-8");
%>

or

<%
response.setContentType('application/json;charset=utf-8");
%>

Sample
<%
response.setContentType('application/json');
var x = {'Element1':'Element2'};
document.write(JSON.stringify(x));
%>
recommendation-more-help
experience-cloud-kcs-help-kbarticles