<?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: XMLHttpRequest and response encoding in Fusion Manage Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13017397#M138</link>
    <description>&lt;P&gt;Thank you, Philip.&lt;/P&gt;&lt;P&gt;Setting the request header helped.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2024 18:48:35 GMT</pubDate>
    <dc:creator>daniel.wrzesniewski</dc:creator>
    <dc:date>2024-09-12T18:48:35Z</dc:date>
    <item>
      <title>XMLHttpRequest and response encoding</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13016878#M136</link>
      <description>&lt;P&gt;I use&amp;nbsp;XMLHttpRequest in an action script to get some informations from my tenant.&lt;/P&gt;&lt;P&gt;Everything works fine but I have problem with response encoding.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is piece of the json&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;"description":"WrzeÅ›niewski, Daniel","details":{"descriptor":"WrzeÅ›niewski,&lt;/PRE&gt;&lt;P&gt;How can I set&amp;nbsp; the correct encoding?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 14:49:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13016878#M136</guid>
      <dc:creator>daniel.wrzesniewski</dc:creator>
      <dc:date>2024-09-12T14:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: XMLHttpRequest and response encoding</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13017202#M137</link>
      <description>&lt;P&gt;I tried the script below, and made this example work.&lt;/P&gt;&lt;P&gt;The intention is to run a GET on this item, and copy the Description into Result.&lt;/P&gt;&lt;P&gt;[This is absolutely NOT the way to write a script more generally, and interrogating a tenant via API is absolutely the &lt;STRONG&gt;last&lt;/STRONG&gt; resort, not the first resort, but anyway...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At line 5 you can see the charset is specified in the Accept header.&lt;/P&gt;&lt;P&gt;The result is what we want...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="philipfrench_0-1726160726983.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1408629iD78B9767EA4F44C4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="philipfrench_0-1726160726983.png" alt="philipfrench_0-1726160726983.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't include the charset in the Accept, you get a string encoded into whatever charset the server thinks you deserve, and when this it written to a field expecting utf8, you get a mess...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="philipfrench_1-1726160759213.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1408630i378EE84818933BD1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="philipfrench_1-1726160759213.png" alt="philipfrench_1-1726160759213.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I suspect this is what you are seeing.&lt;/P&gt;&lt;P&gt;Try including the charset in the Accept...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;var req = new XMLHttpRequest();
req.open("GET", tenantUrl + '/api/v3/workspaces/'+item.master.workspaceID+'/items/'+item.master.dmsID , false);  
prepareRequest(req);

req.setRequestHeader('Accept', 'application/json;charset=UTF-8');

req.send();

var jsonObj = JSON.parse( req.responseText );

for (var i in jsonObj.sections) {
    var section = jsonObj.sections[i];
    for (var j in section.fields) {
        var field = section.fields[j];
        if (field.title == 'Description') {
            item.RESULT = field.value+' at '+new Date();
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 17:09:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13017202#M137</guid>
      <dc:creator>philipfrench</dc:creator>
      <dc:date>2024-09-12T17:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: XMLHttpRequest and response encoding</title>
      <link>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13017397#M138</link>
      <description>&lt;P&gt;Thank you, Philip.&lt;/P&gt;&lt;P&gt;Setting the request header helped.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 18:48:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-manage-forum/xmlhttprequest-and-response-encoding/m-p/13017397#M138</guid>
      <dc:creator>daniel.wrzesniewski</dc:creator>
      <dc:date>2024-09-12T18:48:35Z</dc:date>
    </item>
  </channel>
</rss>

