<?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: Error publishing feature layer using ModelBuilder in ArcGIS Pro in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1367021#M77036</link>
    <description>&lt;P&gt;Andrew,&lt;/P&gt;&lt;P&gt;Your solution worked for me and has put an end to several hours of banging my head against the wall. Adding&amp;nbsp;&lt;SPAN&gt;aprx.save() before m.getWebLayerSharingDraft seems to have worked for me.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2024 21:59:01 GMT</pubDate>
    <dc:creator>CassHonebein2</dc:creator>
    <dc:date>2024-01-05T21:59:01Z</dc:date>
    <item>
      <title>Error publishing feature layer using ModelBuilder in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1336329#M73831</link>
      <description>&lt;P&gt;I've created a model in ArcGIS Pro ModelBuilder which attempts to carry out the following:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Variable: Database connection (sql server)&lt;/LI&gt;&lt;LI&gt;Make Query Layer (input = Database Connection, output = "Dwellings SQL")&lt;/LI&gt;&lt;LI&gt;Make Feature Layer (input = "Dwellings SQL", output = "Dwellings")&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Then using the code in the following resource:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping/publish-and-overwrite-web-layers-in-modelbuilder/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping/publish-and-overwrite-web-layers-in-modelbuilder/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I created a toolbox which should publish (overwrite) a layer called "Dwellings" in our AGOL account. I have tweaked the code in the ScriptTool function as such:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;def&lt;/SPAN&gt; &lt;SPAN class=""&gt;ScriptTool&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;map&lt;/SPAN&gt;, service, summary, tags, description, overwriteService, enableEditing, enableSync, enableWFS, timezone, share_public, share_organization, share_groups, outdir&lt;/SPAN&gt;):
&lt;SPAN class=""&gt;"""ScriptTool function docstring"""&lt;/SPAN&gt;

&lt;SPAN class=""&gt;# Set output file names&lt;/SPAN&gt;
sddraft_filename = service + &lt;SPAN class=""&gt;".sddraft"&lt;/SPAN&gt;
sddraft_output_filename = os.path.join(outdir, sddraft_filename)

&lt;SPAN class=""&gt;# Reference map to publish&lt;/SPAN&gt;
aprx = arcpy.mp.ArcGISProject(&lt;SPAN class=""&gt;"CURRENT"&lt;/SPAN&gt;)
m = aprx.listMaps(&lt;SPAN class=""&gt;map&lt;/SPAN&gt;)[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]
selected_layer = m.listLayers()[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]

&lt;SPAN class=""&gt;# Create FeatureSharingDraft and set service properties&lt;/SPAN&gt;
sharing_draft = m.getWebLayerSharingDraft(&lt;SPAN class=""&gt;"HOSTING_SERVER"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"FEATURE"&lt;/SPAN&gt;, service, [selected_layer])
sharing_draft.summary = summary
sharing_draft.tags = tags
sharing_draft.description = description
sharing_draft.credits = &lt;SPAN class=""&gt;"My Credits"&lt;/SPAN&gt;
sharing_draft.useLimitations = &lt;SPAN class=""&gt;"My Use Limitations"&lt;/SPAN&gt;
sharing_draft.overwriteExistingService = overwriteService

&lt;SPAN class=""&gt;# Create Service Definition Draft file&lt;/SPAN&gt;
sharing_draft.exportToSDDraft(sddraft_output_filename)
outsddraft = sddraft_output_filename
arcpy.AddMessage(&lt;SPAN class=""&gt;"Service definition draft created"&lt;/SPAN&gt;)

&lt;SPAN class=""&gt;# Modify capabilities&lt;/SPAN&gt;
&lt;SPAN class=""&gt;if&lt;/SPAN&gt; enableEditing &lt;SPAN class=""&gt;or&lt;/SPAN&gt; enableSync:
    ModifyCapabilities(sddraft_output_filename, enableEditing, enableSync)
&lt;SPAN class=""&gt;if&lt;/SPAN&gt; enableWFS:
    EnableWFS(sddraft_output_filename)

&lt;SPAN class=""&gt;# Set time zone&lt;/SPAN&gt;
&lt;SPAN class=""&gt;if&lt;/SPAN&gt;(timezone != &lt;SPAN class=""&gt;""&lt;/SPAN&gt;):
    property_set = [{
        &lt;SPAN class=""&gt;"key"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"dateFieldsRespectsDayLightSavingTime"&lt;/SPAN&gt;,
        &lt;SPAN class=""&gt;"value"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;
    },
        {
            &lt;SPAN class=""&gt;"key"&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"dateFieldsTimezoneID"&lt;/SPAN&gt;,
            &lt;SPAN class=""&gt;"value"&lt;/SPAN&gt;: timezone
        }]
    SetTimezone(sddraft_output_filename, property_set=property_set)

&lt;SPAN class=""&gt;# Create Service Definition file&lt;/SPAN&gt;
sd_filename = service + &lt;SPAN class=""&gt;".sd"&lt;/SPAN&gt;
sd_output_filename = os.path.join(outdir, sd_filename)
arcpy.StageService_server(sddraft_output_filename, sd_output_filename)
arcpy.AddMessage(&lt;SPAN class=""&gt;"Service definition created"&lt;/SPAN&gt;)

&lt;SPAN class=""&gt;# Upload to portal&lt;/SPAN&gt;
output = arcpy.UploadServiceDefinition_server(sd_output_filename, &lt;SPAN class=""&gt;"My Hosted Services"&lt;/SPAN&gt;, in_override=&lt;SPAN class=""&gt;"OVERRIDE_DEFINITION"&lt;/SPAN&gt;, in_public=share_public, in_organization=share_organization, in_groups=share_groups)
arcpy.AddMessage(&lt;SPAN class=""&gt;"Service published"&lt;/SPAN&gt;)

&lt;SPAN class=""&gt;return&lt;/SPAN&gt; output[&lt;SPAN class=""&gt;5&lt;/SPAN&gt;]&lt;/PRE&gt;&lt;P&gt;...so that the function will publish a feature layer rather than the whole map. On running the code I receive the following error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 1179, in StageService raise e File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\server.py", line 1176, in StageService retval = convertArcObjectToPythonObject(gp.StageService_server(*gp_fixargs((in_service_definition_draft, out_service_definition, staging_version), True))) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing_base.py", line 512, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 001272: Analyzer errors were encountered ([{"code":"00102","message":"Selected layer does not contain a required layer type for web feature layer","object":"Map"}]). Failed to execute (StageService).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Failed script Publish Web Feature Layer... Failed to execute (Publish Web Feature Layer).&lt;/P&gt;&lt;P&gt;I can't understand why this is happening as the current map does display the imported feature layer and when running the section of the code under #Reference map to publish in the python console it does find the "Dwellings" feature layer. The line of code which throws the error is:&lt;/P&gt;&lt;PRE&gt;arcpy.StageService_server(sddraft_output_filename, sd_output_filename)&lt;/PRE&gt;&lt;P&gt;...and the error message isn't very helpful, I can't find any helpful documentation on Esri's website which details if the problem is with the feature layer or a bug in the code.&lt;/P&gt;&lt;P&gt;I am using ArcGIS Pro 3.1.3 with the default arcgispro-py3 environment.&lt;/P&gt;&lt;P&gt;Below is a diagram of my model:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="8aSu8.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82678i1FB429364E244681/image-size/large?v=v2&amp;amp;px=999" role="button" title="8aSu8.png" alt="8aSu8.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;Below are the parameters I used as per the Esri article:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nzaIM.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82680iFDBE885BEF8D199B/image-size/large?v=v2&amp;amp;px=999" role="button" title="nzaIM.png" alt="nzaIM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any suggestions/assistance would be gratefully received.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 16:48:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1336329#M73831</guid>
      <dc:creator>AndrewFerguson2</dc:creator>
      <dc:date>2023-10-09T16:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Error publishing feature layer using ModelBuilder in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1337910#M73992</link>
      <description>&lt;P&gt;Hi Andrew,&lt;BR /&gt;&lt;BR /&gt;I am having a similar problem and thought I'd share my experience in case we can find some common issue.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The key here seems to be the enabling of 'Feature Service' as it relates to the specific table I'm dealing with.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Do you have this problem with other data in your database or just the `Dwellings` feature layer?&lt;/P&gt;&lt;P&gt;I believe this is, in fact, related to the data set in question, not because the error indicates it but because when I publish any of my other 61 map services with other data in them I am not getting this error.&lt;BR /&gt;&lt;BR /&gt;Some other things that I can add are:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;When I perform the same exact process in the ArcGIS Pro 'Share' 'web layer' interface I get no analyzer errors.&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;If I publish as a Map Image Layer (without feature access enabled), using my script &lt;/SPAN&gt;I get no analyzer errors. and the service is successfully published.&lt;/LI&gt;&lt;LI&gt;On the machine where this code is deployed from (the server*)&amp;nbsp;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;arcpy.GetInstallInfo()[&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Version"&lt;/SPAN&gt;&lt;SPAN&gt;] == '11.1' &lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;On my workstation where i run ArcGIS Pro (in the Analysis/Python/Python Window)&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;arcpy.GetInstallInfo()[&lt;SPAN class=""&gt;"Version"&lt;/SPAN&gt;] == '3.1.2'&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;*&amp;nbsp;C:\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\Scripts\proenv.bat&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 19:32:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1337910#M73992</guid>
      <dc:creator>maxsquires2</dc:creator>
      <dc:date>2023-10-13T19:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error publishing feature layer using ModelBuilder in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1340295#M74249</link>
      <description>&lt;P&gt;Hi Max.&lt;/P&gt;&lt;P&gt;I've now got a working solution. I ended up exporting the model as a .py file so that I could attempt to debug the code.&lt;/P&gt;&lt;P&gt;Firstly I changed the "arcpy.management.MakeFeatureLayer()" function to "arcpy.FeatureClassToFeatureClass_conversion" and provided the query layer to that as a parameter. This still seemed to throw the same error.&lt;/P&gt;&lt;P&gt;I then tried it again after saving the project file and it worked.&lt;/P&gt;&lt;P&gt;It would appear that the Analyzer was throwing a wobble because although arcpy was able to select the layers currently visible on the opened map, it wasn't able to publish any because the project file wasn't saved.&amp;nbsp;I added the:&lt;/P&gt;&lt;P&gt;aprx.save()&lt;/P&gt;&lt;P&gt;...command into the ScriptTool() function ("aprx" is a variable representing the project file) and this seemed to resolve the issue (it would be handy for this to have been detailed in the error message returned by the Analyzer).&lt;/P&gt;&lt;P&gt;Not sure if this solution can be applied to your issue as well but do let me know if it helps and thank you for your reply.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 07:56:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1340295#M74249</guid>
      <dc:creator>AndrewFerguson2</dc:creator>
      <dc:date>2023-10-22T07:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error publishing feature layer using ModelBuilder in ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1367021#M77036</link>
      <description>&lt;P&gt;Andrew,&lt;/P&gt;&lt;P&gt;Your solution worked for me and has put an end to several hours of banging my head against the wall. Adding&amp;nbsp;&lt;SPAN&gt;aprx.save() before m.getWebLayerSharingDraft seems to have worked for me.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2024 21:59:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/error-publishing-feature-layer-using-modelbuilder/m-p/1367021#M77036</guid>
      <dc:creator>CassHonebein2</dc:creator>
      <dc:date>2024-01-05T21:59:01Z</dc:date>
    </item>
  </channel>
</rss>

