<?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: Token working in Postman but not in web application in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1581268#M86451</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/445802"&gt;@NileshValwaikar&lt;/a&gt;&amp;nbsp;, Try removing the referrer configuration or adding the protocol and domain.&amp;nbsp; The * is only allowed as a subdomain (&lt;SPAN&gt;https&lt;/SPAN&gt;&lt;SPAN&gt;://*.your-app.com)&lt;/SPAN&gt;. If you want to allow it to be used from everywhere just leave the referrer empty.&amp;nbsp; I believe that it's probably working in Postman because postman likely doesn't send a referrer by default.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Feb 2025 13:26:02 GMT</pubDate>
    <dc:creator>Sage_Wall</dc:creator>
    <dc:date>2025-02-03T13:26:02Z</dc:date>
    <item>
      <title>Token working in Postman but not in web application</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1581141#M86450</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to export a shapefile for a featurelayer which has export enabled. everything is working manually and also from postman, but when i am trying to integrate the same in my javascript web application its giving code 498 Invalid Token. This token is generated fresh having referrer ="*" and expiry of 15days. as said its working in postman but not in my simple HTML code also.&lt;/P&gt;&lt;P&gt;below is a sample snippet of my code...&lt;/P&gt;&lt;P&gt;const formdata = new FormData();&lt;BR /&gt;formdata.append("itemId", "33cfb3f2849e4793b6551512e0eddac8");&lt;BR /&gt;formdata.append("exportFormat", "Shapefile");&lt;BR /&gt;formdata.append("token", "MyTOKEN");&lt;BR /&gt;formdata.append("exportParameters", "{\n \"layers\" :[ {\"id\" : 0,\"where\" : \"ward_name = 'Bagahada'\"}]\n}");&lt;BR /&gt;formdata.append("f", "json");&lt;BR /&gt;formdata.append("title", "testshp4");&lt;/P&gt;&lt;P&gt;const requestOptions = {&lt;BR /&gt;method: "POST",&lt;BR /&gt;body: formdata,&lt;BR /&gt;redirect: "follow"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;fetch("&lt;A href="https://myportal/portal/sharing/rest/content/users/portaladmin/export" target="_blank"&gt;https://myportal/portal/sharing/rest/content/users/portaladmin/export&lt;/A&gt;", requestOptions)&lt;BR /&gt;.then((response) =&amp;gt; response.text())&lt;BR /&gt;.then((result) =&amp;gt; console.log(result))&lt;BR /&gt;.catch((error) =&amp;gt; console.error(error));&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2025 15:54:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1581141#M86450</guid>
      <dc:creator>NileshValwaikar</dc:creator>
      <dc:date>2025-02-02T15:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Token working in Postman but not in web application</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1581268#M86451</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/445802"&gt;@NileshValwaikar&lt;/a&gt;&amp;nbsp;, Try removing the referrer configuration or adding the protocol and domain.&amp;nbsp; The * is only allowed as a subdomain (&lt;SPAN&gt;https&lt;/SPAN&gt;&lt;SPAN&gt;://*.your-app.com)&lt;/SPAN&gt;. If you want to allow it to be used from everywhere just leave the referrer empty.&amp;nbsp; I believe that it's probably working in Postman because postman likely doesn't send a referrer by default.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 13:26:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1581268#M86451</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2025-02-03T13:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Token working in Postman but not in web application</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1588467#M86558</link>
      <description>&lt;P&gt;When using FormData, you don't need to manually set the Content-Type header, as it will be automatically set by the browser. However, if you manually set the Content-Type to something like application/x-www-form-url encoded or multipart/form-data, it might conflict with the request.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Remove any manual Content-Type header if it's set in your fetch request.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const formdata = new FormData();
formdata.append("itemId", "33cfb3f2849e4793b6551512e0eddac8");
formdata.append("exportFormat", "Shapefile");
formdata.append("token", "MyTOKEN");
formdata.append("exportParameters", "{\n \"layers\" :[ {\"id\" : 0,\"where\" : \"ward_name = 'Bagahada'\"}]\n}");
formdata.append("f", "json");
formdata.append("title", "testshp4");

const requestOptions = {
  method: "POST",
  body: formdata,
  headers: {
    "Referer": "https://your-web-app.com",  // Adjust with your web app URL if necessary
  },
  redirect: "follow"
};

fetch("https://myportal/portal/sharing/rest/content/users/portaladmin/export", requestOptions)
  .then(response =&amp;gt; {
    // Check if the response is ok
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response.text();
  })
  .then(result =&amp;gt; {
    console.log("Export result: ", result);
  })
  .catch(error =&amp;gt; {
    console.error("Fetch error: ", error);
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2025 11:24:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/token-working-in-postman-but-not-in-web/m-p/1588467#M86558</guid>
      <dc:creator>nafizpervez</dc:creator>
      <dc:date>2025-02-24T11:24:34Z</dc:date>
    </item>
  </channel>
</rss>

