<?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: FeatureLayer.addAttachments returns error - Unexpected token in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613388#M87124</link>
    <description>&lt;P&gt;Hi Noah,&lt;/P&gt;&lt;P&gt;I tried different attachments and the same error happens. The mapping is part of a bigger application.&amp;nbsp; Originally, it was .net framework MVC and the code was working fine. Recently, we upgraded to .net core 8 and the same code fails.&lt;/P&gt;</description>
    <pubDate>Fri, 09 May 2025 18:48:21 GMT</pubDate>
    <dc:creator>MKY</dc:creator>
    <dc:date>2025-05-09T18:48:21Z</dc:date>
    <item>
      <title>FeatureLayer.addAttachments returns error - Unexpected token</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613228#M87119</link>
      <description>&lt;P&gt;I have a popup trigger "Add Attachment". It invokes a function to dynamically create a form and select an attachment.&lt;/P&gt;&lt;P&gt;It returns an error :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MKY_0-1746798310501.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/131869iF2707B70FDE41F86/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MKY_0-1746798310501.png" alt="MKY_0-1746798310501.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The function addAttachment&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addAttachment(feature) { 
//create form 
const attachmentForm = document.createElement("form"); attachmentForm.setAttribute("id", "addAttachmentForm"); 
let fileSelector = document.createElement("input"); fileSelector.setAttribute("id", "fileSelector"); fileSelector.setAttribute("type", "file"); 
fileSelector.setAttribute("name", "attachment"); 
let entInput = document.createElement("input"); 
entInput.setAttribute("type", "hidden"); 
entInput.setAttribute("name", "f"); 
entInput.setAttribute("value", "json"); attachmentForm.appendChild(fileSelector); attachmentForm.appendChild(entInput); document.getElementById("resource-container").appendChild(attachmentForm); document.getElementById("fileSelector").addEventListener("change", (e) =&amp;gt; { let selectedFiles = (e.target as any).files;
let layer = feature.layer; 
layer.addAttachment(feature, attachmentForm).then((result) =&amp;gt; { console.log("attachment added. If successful it will return the objectID of the feature ", result);
  } }).catch((error) =&amp;gt; { 
console.log("attachment adding failed: ", error); 
 }); 
 document.getElementById("fileSelector").click();
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 13:54:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613228#M87119</guid>
      <dc:creator>MKY</dc:creator>
      <dc:date>2025-05-09T13:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer.addAttachments returns error - Unexpected token</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613273#M87121</link>
      <description>&lt;P&gt;Looks like the attachment may be invalid? I would try several different attachment and/or attachment types.&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 15:36:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613273#M87121</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2025-05-09T15:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer.addAttachments returns error - Unexpected token</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613388#M87124</link>
      <description>&lt;P&gt;Hi Noah,&lt;/P&gt;&lt;P&gt;I tried different attachments and the same error happens. The mapping is part of a bigger application.&amp;nbsp; Originally, it was .net framework MVC and the code was working fine. Recently, we upgraded to .net core 8 and the same code fails.&lt;/P&gt;</description>
      <pubDate>Fri, 09 May 2025 18:48:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-addattachments-returns-error/m-p/1613388#M87124</guid>
      <dc:creator>MKY</dc:creator>
      <dc:date>2025-05-09T18:48:21Z</dc:date>
    </item>
  </channel>
</rss>

