<?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 Use ArcGIS REST API from a backend service, scripts, api proxy, cron jobs etc.. in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/use-arcgis-rest-api-from-a-backend-service-scripts/m-p/1263920#M4396</link>
    <description>&lt;P&gt;For a client I need to be able to add attributes to a feature server. I identified 2 endpoints that works except I don't understand how the authentication works from a internal system.&lt;/P&gt;&lt;P&gt;endpoint 1: POST&amp;nbsp;&lt;SPAN&gt;/arcgis/rest/admin/services/&amp;lt;service&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/FeatureServer/&amp;lt;layer&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/addToDefinition&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;endpoint 2: POST&amp;nbsp;&lt;SPAN&gt;arcgis/rest/services/&amp;lt;service&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/FeatureServer/&amp;lt;layer&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/updateFeatures&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can I&amp;nbsp;authenticate these requests in a internal system like a cron job, script etc...?&lt;/P&gt;&lt;P&gt;I tryed the api key&amp;nbsp; but doesn't seem to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could just use&amp;nbsp;&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;with username and password. Store the token and refetch if expired but that doesn't seem like a best practice.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2023 09:32:52 GMT</pubDate>
    <dc:creator>Jort</dc:creator>
    <dc:date>2023-03-03T09:32:52Z</dc:date>
    <item>
      <title>Use ArcGIS REST API from a backend service, scripts, api proxy, cron jobs etc..</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/use-arcgis-rest-api-from-a-backend-service-scripts/m-p/1263920#M4396</link>
      <description>&lt;P&gt;For a client I need to be able to add attributes to a feature server. I identified 2 endpoints that works except I don't understand how the authentication works from a internal system.&lt;/P&gt;&lt;P&gt;endpoint 1: POST&amp;nbsp;&lt;SPAN&gt;/arcgis/rest/admin/services/&amp;lt;service&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/FeatureServer/&amp;lt;layer&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/addToDefinition&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;endpoint 2: POST&amp;nbsp;&lt;SPAN&gt;arcgis/rest/services/&amp;lt;service&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/FeatureServer/&amp;lt;layer&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/updateFeatures&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can I&amp;nbsp;authenticate these requests in a internal system like a cron job, script etc...?&lt;/P&gt;&lt;P&gt;I tryed the api key&amp;nbsp; but doesn't seem to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could just use&amp;nbsp;&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;with username and password. Store the token and refetch if expired but that doesn't seem like a best practice.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 09:32:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/use-arcgis-rest-api-from-a-backend-service-scripts/m-p/1263920#M4396</guid>
      <dc:creator>Jort</dc:creator>
      <dc:date>2023-03-03T09:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Use ArcGIS REST API from a backend service, scripts, api proxy, cron jobs etc..</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/use-arcgis-rest-api-from-a-backend-service-scripts/m-p/1263931#M4397</link>
      <description>&lt;P&gt;Hi Jort,&lt;/P&gt;&lt;P&gt;I recommend generating the token each time you are making a post request.&amp;nbsp; Python Ex:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests, json

# Generate Token
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'http://www.arcgis.com'}
r = requests.post(tokenURL, data = params, verify=False)
response = json.loads(r.content)
token = response['token']

# Post Request
.....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 11:33:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/use-arcgis-rest-api-from-a-backend-service-scripts/m-p/1263931#M4397</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2023-03-03T11:33:57Z</dc:date>
    </item>
  </channel>
</rss>

