<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why is the REST API modular input response xml data charset is broken? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379777#M46194</link>
    <description>&lt;P&gt;It seems like your broken text is encoded with iso-8859-1(Latin1). Is the first line of your responsehandler.py "coding: utf-8" just a typo? It should be something like "#-&lt;EM&gt;- coding: utf-8 -&lt;/EM&gt;-". &lt;/P&gt;</description>
    <pubDate>Wed, 02 May 2018 15:41:44 GMT</pubDate>
    <dc:creator>asohahn_splunk</dc:creator>
    <dc:date>2018-05-02T15:41:44Z</dc:date>
    <item>
      <title>Why is the REST API modular input response xml data charset is broken?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379776#M46193</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
i have a problem with the character set.&lt;/P&gt;

&lt;P&gt;I am using the REST API modular input.&lt;BR /&gt;
However, characters are broken in the xml data received in response through the REST API.&lt;BR /&gt;
like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;tag1&amp;gt;
&amp;lt;![CDATA[ì&amp;#156; ì&amp;#152;&amp;#129;ë¯¸ì&amp;#157;&amp;#152; ë§&amp;#136;ì&amp;#157;&amp;#140;ì&amp;#157;&amp;#128; ì&amp;#150;¸ì &amp;#156;ë&amp;#130;&amp;#152; ì²­ì¶&amp;#152;]]&amp;gt;
&amp;lt;/tag1&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried this thing: &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;modify props.conf&lt;/P&gt;

&lt;P&gt;[sourcetype]&lt;BR /&gt;
CHARSET = UTF-8&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;modify responsehandler.py &lt;/P&gt;

&lt;P&gt;coding: utf-8&lt;BR /&gt;
import sys&lt;BR /&gt;
reload(sys)&lt;BR /&gt;
sys.setdefaultencoding('utf-8')&lt;/P&gt;

&lt;P&gt;import json&lt;BR /&gt;
import datetime&lt;/P&gt;

&lt;P&gt;class MyResponseHandler:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;def __init__(self,**args):
    pass

def __call__(self, response_object,raw_response_output,response_type,req_args,endpoint):
    cookies = response_object.cookies
    if cookies:
        req_args["cookies"] = cookies
    raw_response_output.encode('utf-8')
    print_xml_stream(raw_response_output)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;....(skip)&lt;BR /&gt;
what should I do?&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 02 May 2018 11:23:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379776#M46193</guid>
      <dc:creator>leeyounsoo</dc:creator>
      <dc:date>2018-05-02T11:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the REST API modular input response xml data charset is broken?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379777#M46194</link>
      <description>&lt;P&gt;It seems like your broken text is encoded with iso-8859-1(Latin1). Is the first line of your responsehandler.py "coding: utf-8" just a typo? It should be something like "#-&lt;EM&gt;- coding: utf-8 -&lt;/EM&gt;-". &lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 15:41:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379777#M46194</guid>
      <dc:creator>asohahn_splunk</dc:creator>
      <dc:date>2018-05-02T15:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the REST API modular input response xml data charset is broken?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379778#M46195</link>
      <description>&lt;P&gt;that is a typo. &lt;BR /&gt;
splunk answer comment form automatically change that String.&lt;/P&gt;

&lt;P&gt;i write like this : &lt;BR /&gt;
"# -&lt;EM&gt;- coding : utf-8 -&lt;/EM&gt;-"  &lt;/P&gt;

&lt;P&gt;but, that is broken yet.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;my python version is 2.7.x&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 03 May 2018 01:53:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-the-REST-API-modular-input-response-xml-data-charset-is/m-p/379778#M46195</guid>
      <dc:creator>leeyounsoo</dc:creator>
      <dc:date>2018-05-03T01:53:29Z</dc:date>
    </item>
  </channel>
</rss>

