<?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 Change Title in sdddraft file when overwriting service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-title-in-sdddraft-file-when-overwriting/m-p/91622#M7154</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When programmatically publishing Map Image Services to ArcGIS Enterprise Portal, it is possible to define the service's title (the one which will be displayed in the item’s portal page after publishing) by modifying the .sddraft file. Please find an example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

layer_sharing_draft &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getWebLayerSharingDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target_server_type&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MAP_IMAGE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; service_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Create Service Definition Draft file&lt;/SPAN&gt;
layer_sharing_draft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exportToSDDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Modify title in sddraft file &lt;/SPAN&gt;
xml_sddraft &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; DOM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;parse&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
title &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; xml_sddraft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getElementsByTagName&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Title'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
title&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;firstChild&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; service_title

&lt;SPAN class="comment token"&gt;# save as new sddraft file&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; codecs&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_sddraft_path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"w"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"utf-8"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
	xml_sddraft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;writexml&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;writer&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; encoding&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"utf-8"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
	f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_sddraft_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
		
&lt;SPAN class="comment token"&gt;# stage service			&lt;/SPAN&gt;
sd_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;StageService_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_sddraft_path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sd_file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  
		
&lt;SPAN class="comment token"&gt;# upload service definition&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UploadServiceDefinition_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sd_file&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; target_url&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While this works when creating services, it does not work when overwriting them. (when layer_sharing_draft.overwriteExistingService = True)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when I overwrite an existing service, the title in the variable "service_title"&amp;nbsp;is not shown as title in the service's portal page as I would expect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question is: Is it possible to edit the &lt;SPAN&gt;.sddraft&lt;/SPAN&gt;&amp;nbsp;file in such a way that the service title&amp;nbsp;is changed when overwriting the service? Or is there another way to accomplish this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:30:42 GMT</pubDate>
    <dc:creator>LukasWürsch</dc:creator>
    <dc:date>2021-12-10T23:30:42Z</dc:date>
    <item>
      <title>Change Title in sdddraft file when overwriting service</title>
      <link>https://community.esri.com/t5/python-questions/change-title-in-sdddraft-file-when-overwriting/m-p/91622#M7154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When programmatically publishing Map Image Services to ArcGIS Enterprise Portal, it is possible to define the service's title (the one which will be displayed in the item’s portal page after publishing) by modifying the .sddraft file. Please find an example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

layer_sharing_draft &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getWebLayerSharingDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;target_server_type&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MAP_IMAGE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; service_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Create Service Definition Draft file&lt;/SPAN&gt;
layer_sharing_draft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exportToSDDraft&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Modify title in sddraft file &lt;/SPAN&gt;
xml_sddraft &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; DOM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;parse&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sddraft_file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
title &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; xml_sddraft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getElementsByTagName&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Title'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
title&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;firstChild&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; service_title

&lt;SPAN class="comment token"&gt;# save as new sddraft file&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; codecs&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_sddraft_path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"w"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"utf-8"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; f&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
	xml_sddraft&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;writexml&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;writer&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; encoding&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"utf-8"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
	f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_sddraft_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
		
&lt;SPAN class="comment token"&gt;# stage service			&lt;/SPAN&gt;
sd_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;StageService_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;new_sddraft_path&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sd_file_path&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  
		
&lt;SPAN class="comment token"&gt;# upload service definition&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UploadServiceDefinition_server&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sd_file&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; target_url&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While this works when creating services, it does not work when overwriting them. (when layer_sharing_draft.overwriteExistingService = True)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when I overwrite an existing service, the title in the variable "service_title"&amp;nbsp;is not shown as title in the service's portal page as I would expect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question is: Is it possible to edit the &lt;SPAN&gt;.sddraft&lt;/SPAN&gt;&amp;nbsp;file in such a way that the service title&amp;nbsp;is changed when overwriting the service? Or is there another way to accomplish this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:30:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-title-in-sdddraft-file-when-overwriting/m-p/91622#M7154</guid>
      <dc:creator>LukasWürsch</dc:creator>
      <dc:date>2021-12-10T23:30:42Z</dc:date>
    </item>
  </channel>
</rss>

