<?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: How can I can edit public Feature-Layer BUT with authorised request ONLY? in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-can-i-can-edit-public-feature-layer-but-with/m-p/1115777#M4004</link>
    <description>&lt;P&gt;The way I would handle this is to first un-share the source hosted feature layer which has editing enabled so appropriate credentials are needed to perform an edit.&amp;nbsp; Then I would &lt;A href="https://doc.arcgis.com/en/arcgis-online/manage-data/create-hosted-views.htm" target="_self"&gt;create a hosted layer view&lt;/A&gt;&amp;nbsp;and disable editing and share it publicly for others to consume as a read-only layer.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Nov 2021 18:43:08 GMT</pubDate>
    <dc:creator>JohnGrayson</dc:creator>
    <dc:date>2021-11-10T18:43:08Z</dc:date>
    <item>
      <title>How can I can edit public Feature-Layer BUT with authorised request ONLY?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-can-i-can-edit-public-feature-layer-but-with/m-p/1115646#M4003</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a public Feature-Layer. My intention is to:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Update my layer automatically using with Firebase Cloud-Functions (written in node.js)&lt;/LI&gt;&lt;LI&gt;Keep sharing my layer publicly&lt;/LI&gt;&lt;LI&gt;But keep my layer non-editable for unauthorised users&lt;/LI&gt;&lt;LI&gt;I wish to use my API-Key for authentication (but alternatively can use&amp;nbsp;OAuth 2.0 Credentials)&lt;/LI&gt;&lt;LI&gt;I don't care which method specifically: Append/Upsert, applyEdits, Update Feature etc...&lt;/LI&gt;&lt;LI&gt;I don't care if I use Arc-GIS REST API or JS etc...&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;STRONG&gt;My problem:&lt;/STRONG&gt;&lt;SPAN&gt; If I edit my feature definition to &lt;/SPAN&gt;"capabilities" : "Create, Update, Delete"&lt;SPAN&gt;as mentioned &lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/apply-edits-feature-service-layer-.htm" target="_blank" rel="nofollow noopener noreferrer"&gt;here&lt;/A&gt;&lt;SPAN&gt;, then any unauthorised user can edit my layer, while if I don't, I get:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;[ 'This operation is not supported.', 'Unable to add the features.', 'This operation is not supported.' ]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Authentication is declered &lt;A href="https://esri.github.io/arcgis-rest-js/api/feature-layer/applyEdits/" target="_blank" rel="nofollow noopener noreferrer"&gt;in the documentation&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;My example code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require("cross-fetch/polyfill");
require("isomorphic-form-data");
const featureLayer = require('@esri/arcgis-rest-feature-layer');
const auth = require('@esri/arcgis-rest-auth');

const session = new auth.ApplicationSession({
  clientId: "Some clientId",
  clientSecret: "Some clientSecret"
})
const apiKey = new auth.ApiKey({key: 'Some API Key'});

featureLayer.applyEdits({
    url: "https://services3.arcgis.com/someID/arcgis/rest/services/someNAME/FeatureServer/0",
    adds: [{
      geometry: { x: 120, y: 45 },
      attributes: { indexCity: "alive" }
    }],
    authentication: session // or alternativly: "apiKey"
  })
    .then(response =&amp;gt; {
      console.log(response)
    })
    .catch(err =&amp;gt; console.log(err.response.error.details));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;&lt;U&gt;&lt;STRONG&gt;How can I keep my Feature-Layer public viewed but editable by me only?&amp;nbsp;&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 14:44:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-can-i-can-edit-public-feature-layer-but-with/m-p/1115646#M4003</guid>
      <dc:creator>arielhasidim</dc:creator>
      <dc:date>2021-11-10T14:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I can edit public Feature-Layer BUT with authorised request ONLY?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-can-i-can-edit-public-feature-layer-but-with/m-p/1115777#M4004</link>
      <description>&lt;P&gt;The way I would handle this is to first un-share the source hosted feature layer which has editing enabled so appropriate credentials are needed to perform an edit.&amp;nbsp; Then I would &lt;A href="https://doc.arcgis.com/en/arcgis-online/manage-data/create-hosted-views.htm" target="_self"&gt;create a hosted layer view&lt;/A&gt;&amp;nbsp;and disable editing and share it publicly for others to consume as a read-only layer.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 18:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-can-i-can-edit-public-feature-layer-but-with/m-p/1115777#M4004</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-11-10T18:43:08Z</dc:date>
    </item>
  </channel>
</rss>

