<?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: Automation to update a vector tile service referenced with feature service in Publishing and Managing Services Questions</title>
    <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1387827#M1140</link>
    <description>&lt;P&gt;&amp;nbsp;To help everybody, this is the Python script we came up with:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import urllib
import json
import requests


### data to be sent for token generation on Portal
token_data = urllib.parse.urlencode({'username' : 'XXX',
                                     'password' : 'YYY',                                     
                                     'referer': 'URL ArcGIS Server with webadaptor',
                                     'expiration': 60,
                                     'f' : ''}).encode('utf-8')

### getting token from ArcGIS server
token_response = urllib.request.urlopen('URL ArcGIS Server with webadaptor' + '/tokens/generateToken',
                                  token_data).read().decode('utf-8')

### vector tile url to request in order to submit cache job
rebuildcacheurl = 'URL ArcGIS Server with webadaptor/rest/services/System/CachingControllers/GPServer/Manage%20Vector%20Tile%20Cache/submitJob?serviceName=ServiceName&amp;amp;serviceFolder=Hosted&amp;amp;tilingFormat=INDEXED&amp;amp;f=json&amp;amp;token='

## header required for cache job request
rebuildcache_headers = {
  'authority': 'Full Computer name of ArcGIs Server location',
  'accept': '*/*',
  'origin': 'URL ArcGIS Portal',
  'referer': 'URL ArcGIS Portal/'}

### submitting cache job
response = requests.request("GET", rebuildcacheurl+token_response, headers=rebuildcache_headers)

print('Job has been submitted')
print('URL ArcGIS Server with webadaptor/rest/services/System/CachingControllers/GPServer/Manage%20Vector%20Tile%20Cache/jobs/'+response.json()['jobId']+'?f=html')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 01:43:16 GMT</pubDate>
    <dc:creator>CharliePatrier</dc:creator>
    <dc:date>2024-02-28T01:43:16Z</dc:date>
    <item>
      <title>Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1332800#M1031</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We are using ArcGIS Entreprise 11.1 with a federated server and we would like to automate the caching of our vector tile layers.&lt;/P&gt;&lt;P&gt;Our vector tile service has an associated, referenced feature service which allows the rebuild cache Rest operation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CharliePatrier_0-1695790237669.png" style="width: 554px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81749iB0D4EA73A77D8744/image-dimensions/554x310?v=v2" width="554" height="310" role="button" title="CharliePatrier_0-1695790237669.png" alt="CharliePatrier_0-1695790237669.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Clicking on the "Rebuild Cache" button is working perfectly, therefore it looks like a great way to automate using this method.&lt;/P&gt;&lt;P&gt;We are aiming to automate the rebuild cache daily by reproducing this rest operation and we tried running the following script:&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="python"&gt;import urllib
import json

'''Retrieves a token to be used with API requests.'''
data = urllib.parse.urlencode({'username' : 'username',
                               'password' : 'password',
                               'client' : 'https://XXX/server/rest/services',
                               'referer': 'https://YYY/portal/sharing/rest',
                               'expiration': 60,
                               'f' : 'json'}).encode('utf-8')

response = urllib.request.urlopen('https://YYY/portal' + '/sharing/rest/generateToken',data).read().decode('utf-8')

rebuildcacheurl = 'https://XXX/server/rest/services/System/CachingControllers/GPServer/Manage%20Vector%20Tile%20Cache/submitJob?serviceName=GX_WGS84_BaseMap&amp;amp;serviceFolder=Hosted&amp;amp;tilingFormat=INDEXED&amp;amp;f=json&amp;amp;token='

token = json.loads(response)['token']

submitjob = urllib.request.urlopen(rebuildcacheurl+token).read().decode('utf-8')&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have been unsuccessful so far and we are receiving this error response:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CharliePatrier_1-1695791002855.png" style="width: 660px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81750iCF304F356488A46A/image-dimensions/660x221?v=v2" width="660" height="221" role="button" title="CharliePatrier_1-1695791002855.png" alt="CharliePatrier_1-1695791002855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have been trying to find documentation but I couldn't get anything which solve our issue.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 05:12:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1332800#M1031</guid>
      <dc:creator>CharliePatrier</dc:creator>
      <dc:date>2023-09-27T05:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1332904#M1032</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/147684"&gt;@CharliePatrier&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Have you tried using Postman to create the request for you? This image may help you get this in the right format &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="A_Wyn_Jones_0-1695821331125.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/81768i691098B79F6408F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="A_Wyn_Jones_0-1695821331125.png" alt="A_Wyn_Jones_0-1695821331125.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Postman can convert cURL requests to python - you then simply need to create a two-stage script.&lt;/P&gt;&lt;P&gt;getToken() (return Token)&lt;/P&gt;&lt;P&gt;rebuildCache(Token)&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 13:30:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1332904#M1032</guid>
      <dc:creator>A_Wyn_Jones</dc:creator>
      <dc:date>2023-09-27T13:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1333202#M1033</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/599132"&gt;@A_Wyn_Jones&lt;/a&gt;&amp;nbsp;it worked this way, very good outcome!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 23:26:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1333202#M1033</guid>
      <dc:creator>CharliePatrier</dc:creator>
      <dc:date>2023-09-27T23:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1378568#M1135</link>
      <description>&lt;P&gt;We took inspiration from your workflow and made a custom FME transformer using HTTPCallers.&lt;/P&gt;&lt;P&gt;For anyone stumbling upon this thread (like we did) looking for a non coding solution:&amp;nbsp;&lt;A href="https://hub.safe.com/publishers/martin-ekstrand/transformers/arcgisenterprisevectortilerebuildcache" target="_blank" rel="nofollow noopener noreferrer"&gt;https://hub.safe.com/publishers/martin-ekstrand/transformers/arcgisenterprisevectortilerebuildcache&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 09:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1378568#M1135</guid>
      <dc:creator>StaffanstorpsKommun</dc:creator>
      <dc:date>2024-02-06T09:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1385955#M1138</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/147684"&gt;@CharliePatrier&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/205423"&gt;@StaffanstorpsKommun&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To revisit this one, You can also call for the recreation of a cache via the ArcGIS Server admin endpoint - this should've been my first suggestion!&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/online/vector-tile-rebuild-cache-feature-service-.htm" target="_blank"&gt;https://developers.arcgis.com/rest/services-reference/online/vector-tile-rebuild-cache-feature-service-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 12:39:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1385955#M1138</guid>
      <dc:creator>A_Wyn_Jones</dc:creator>
      <dc:date>2024-02-23T12:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1386001#M1139</link>
      <description>&lt;P&gt;Only for ArcGIS Online Though&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/599132"&gt;@A_Wyn_Jones&lt;/a&gt;? That particular endpoint does not exist in Enterprise, and you have to use the&amp;nbsp;System/CachingControllers/GPServer/Manage%20Vector%20Tile%20Cache method?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 14:23:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1386001#M1139</guid>
      <dc:creator>StaffanstorpsKommun</dc:creator>
      <dc:date>2024-02-23T14:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1387827#M1140</link>
      <description>&lt;P&gt;&amp;nbsp;To help everybody, this is the Python script we came up with:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import urllib
import json
import requests


### data to be sent for token generation on Portal
token_data = urllib.parse.urlencode({'username' : 'XXX',
                                     'password' : 'YYY',                                     
                                     'referer': 'URL ArcGIS Server with webadaptor',
                                     'expiration': 60,
                                     'f' : ''}).encode('utf-8')

### getting token from ArcGIS server
token_response = urllib.request.urlopen('URL ArcGIS Server with webadaptor' + '/tokens/generateToken',
                                  token_data).read().decode('utf-8')

### vector tile url to request in order to submit cache job
rebuildcacheurl = 'URL ArcGIS Server with webadaptor/rest/services/System/CachingControllers/GPServer/Manage%20Vector%20Tile%20Cache/submitJob?serviceName=ServiceName&amp;amp;serviceFolder=Hosted&amp;amp;tilingFormat=INDEXED&amp;amp;f=json&amp;amp;token='

## header required for cache job request
rebuildcache_headers = {
  'authority': 'Full Computer name of ArcGIs Server location',
  'accept': '*/*',
  'origin': 'URL ArcGIS Portal',
  'referer': 'URL ArcGIS Portal/'}

### submitting cache job
response = requests.request("GET", rebuildcacheurl+token_response, headers=rebuildcache_headers)

print('Job has been submitted')
print('URL ArcGIS Server with webadaptor/rest/services/System/CachingControllers/GPServer/Manage%20Vector%20Tile%20Cache/jobs/'+response.json()['jobId']+'?f=html')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 01:43:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1387827#M1140</guid>
      <dc:creator>CharliePatrier</dc:creator>
      <dc:date>2024-02-28T01:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Automation to update a vector tile service referenced with feature service</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1387938#M1141</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/205423"&gt;@StaffanstorpsKommun&lt;/a&gt;&amp;nbsp; Yes! My apologies, only for ArcGIS Online!&lt;/P&gt;&lt;P&gt;Got excited reading the WRONG documentation &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; Mondays!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 10:15:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/automation-to-update-a-vector-tile-service/m-p/1387938#M1141</guid>
      <dc:creator>A_Wyn_Jones</dc:creator>
      <dc:date>2024-02-28T10:15:25Z</dc:date>
    </item>
  </channel>
</rss>

