<?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: AddToDefinition not working in Portal in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1563167#M4891</link>
    <description>&lt;P&gt;Thanks for this post! I looked at it many times.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anywhere that shows all the inputs for the&amp;nbsp;&lt;STRONG&gt;addToDefinition&amp;nbsp;&lt;/STRONG&gt;payload? i.e. &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service/#example-usage" target="_self"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service/#example-usage&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been able to get this work but I'm not sure what all the values are doing, and which ones are required and can't find this anywhere.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Nov 2024 21:27:57 GMT</pubDate>
    <dc:creator>chris_del101</dc:creator>
    <dc:date>2024-11-27T21:27:57Z</dc:date>
    <item>
      <title>AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1281947#M4465</link>
      <description>&lt;P&gt;I'm trying to create a new hosted feature layer in Portal (ArcGIS Enterprise 10.9) by making a series of calls to the REST API.&lt;/P&gt;&lt;P&gt;What I've tried:&lt;/P&gt;&lt;P&gt;1. POST to&amp;nbsp;&lt;A href="https://{mydomain}/portal/generateToken" target="_blank"&gt;https://{mydomain}/portal/generateToken&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is working.&amp;nbsp; I send valid credentials and get a token in return.&amp;nbsp; I use the received token in the following requests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. POST to&amp;nbsp;&lt;A href="https://{mydomain}/portal/sharing/rest/content/users/{username}/createService?token={token}" target="_blank"&gt;https://{mydomain}/portal/sharing/rest/content/users/{username}/createService?token={token}&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is working.&amp;nbsp; I see the new empty service in the user's content in Portal.&lt;/P&gt;&lt;P&gt;The createService parameter contains the following JSON&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "name": "Test11",
    "serviceDescription": "this is a test",
    "hasStaticData": false,
    "maxRecordCount": 10000,
    "supportedQueryFormats": "JSON",
    "capabilities": "Create,Delete,Query,Update,Editing",
    "description": "this is a test",
    "copyrightText": null,
    "spatialReference": {
        "wkid": 102100
    },
    "initialExtent": null,
    "allowedGeometryUpdate": true,
    "units": "esriMeters",
    "xssPreventionInfo": {
        "xssPreventionEnabled": true,
        "xssPreventionRule": "input",
        "xssInputRule": "rejectInvalid"
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After visiting the new service's Overview page in Portal, I use it's URL to build the next request....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. POST to&amp;nbsp;&lt;A href="https://{mydomain}/server/rest/services/Hosted/Test11/FeatureServer/addToDefinition?f=json&amp;amp;token={token}" target="_blank"&gt;https://{mydomain}/server/rest/services/Hosted/Test11/FeatureServer/addToDefinition?f=json&amp;amp;token={token}&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I add a url encoded key/value pair to the above request body named "addToDefinition" as described in &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service-.htm" target="_self"&gt;this documentation&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "layers": [
        {
            "id": 0,
            "name": "TestLayer01",
            "type": "Feature Layer",
            "defaultVisibility": true,
            "supportedQueryFormats": "JSON", 
            "capabilities": "Create,Delete,Query,Update,Editing,Extract,Sync", 
            "fields": [
                {
                    "name": "FID", 
                    "type": "esriFieldTypeInteger", 
                    "actualType": "int", 
                    "alias": "FID", 
                    "sqlType": "sqlTypeInteger", 
                    "length": 4, 
                    "nullable": false, 
                    "editable": false, 
                    "domain": null, 
                    "defaultValue": null
                },
                {
                    "name": "CATEGORY", 
                    "type": "esriFieldTypeString", 
                    "actualType": "nvarchar", 
                    "alias": "CATEGORY", 
                    "sqlType": "sqlTypeNVarchar", 
                    "length": 40, 
                    "nullable": true, 
                    "editable": true, 
                    "domain": null, 
                    "defaultValue": null
                }
            ]
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;This is not working. Although I get a 200 response, the response body simply contains the empty service's info.&amp;nbsp; No new feature layer has been added to the empty service in portal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I have the request URL wrong, or do I need to include some additional properties in the JSON structure?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 17:28:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1281947#M4465</guid>
      <dc:creator>LNX</dc:creator>
      <dc:date>2023-04-24T17:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1281995#M4466</link>
      <description>&lt;P&gt;I found the problem(s).&amp;nbsp; Unfortunately the documentation does not specify which of the ump-teen properties of "addToDefinition" are required.&amp;nbsp; I've been able to figure them out by trial and error.&amp;nbsp; If anyone else runs into this, here's how I fixed it.&lt;/P&gt;&lt;P&gt;1. First, the request URL was indeed wrong.&amp;nbsp; It needs to be&amp;nbsp;https://{mydomain}/server/rest&lt;STRONG&gt;/admin/&lt;/STRONG&gt;services/Hosted/Test11/FeatureServer/addToDefinition?f=json&amp;amp;token={token}&lt;/P&gt;&lt;P&gt;2. After fixing the URL and resending, I got this error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "error": {
        "code": 500,
        "message": "\"objectIdField\" attribute was not passed in the service definition and SDS did not discover a suitable field.",
        "details": []
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above error indicated that my request JSON addToDefinition object was missing the "objectIdField" property which specifies which of the fields is the objectID.&amp;nbsp; Updating the original request JSON to include the missing property resolves this error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "layers": [
        {
            "id": 0,
            "name": "TestLayer01",
            "type": "Feature Layer",
            "defaultVisibility": true,
            "supportedQueryFormats": "JSON", 
            "capabilities": "Create,Delete,Query,Update,Editing,Extract,Sync", 
            "objectIdField": "FID",
            "fields": [
                {
                    "name": "FID", 
                    "type": "esriFieldTypeInteger", 
                    "actualType": "int", 
                    "alias": "FID", 
                    "sqlType": "sqlTypeInteger", 
                    "length": 4, 
                    "nullable": false, 
                    "editable": false, 
                    "domain": null, 
                    "defaultValue": null
                },
                {
                    "name": "CATEGORY", 
                    "type": "esriFieldTypeString", 
                    "actualType": "nvarchar", 
                    "alias": "CATEGORY", 
                    "sqlType": "sqlTypeNVarchar", 
                    "length": 40, 
                    "nullable": true, 
                    "editable": true, 
                    "domain": null, 
                    "defaultValue": null
                }
            ]
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Next it complained about the "type" property assigned to the object ID field (which in this case is FID).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "error": {
        "code": 500,
        "message": "Wrong type of the ObjectID field.",
        "details": []
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ESRI has a typo in their documentation examples.&amp;nbsp; I needed to change the FID field definition from this...&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"type": "esriFieldTypeInteger"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;to this...&lt;/P&gt;&lt;P&gt;"type": "esriFieldTypeOID"&lt;/P&gt;&lt;P&gt;4. Next it complained about the missing geometryType property.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "error": {
        "code": 500,
        "message": "JSONObject[\"geometryType\"] not found.",
        "details": []
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;So I added&amp;nbsp;"geometryType": "esriGeometryPoint" to the layer definition and kept going.&lt;/P&gt;&lt;P&gt;5. Now it's mad that I didn't specify and extent....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "error": {
        "code": 500,
        "message": "JSONObject[\"extent\"] not found.",
        "details": []
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This one is particularly annoying because I don't necessarily know what my extent will be yet, but since it's a required property I borrowed the extent object from the example in the docs.&amp;nbsp; Moving on...&lt;/P&gt;&lt;P&gt;6. And lastly, it requires the "hasAttachments" property.&amp;nbsp; I set mine to false and resubmitted.&amp;nbsp; Finally some joy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "success": true,
    "layers": [
        {
            "name": "TestLayer01",
            "id": 0
        }
    ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final request JSON that succeeded is below.&amp;nbsp; I think this may be the absolute minimum that's required, although there are many more properties that can be added.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "layers": [
        {
            "id": 0,
            "name": "TestLayer01",
            "type": "Feature Layer",
            "defaultVisibility": true,
            "supportedQueryFormats": "JSON",
            "capabilities": "Create,Delete,Query,Update,Editing,Extract,Sync",
            "geometryType": "esriGeometryPoint",
            "hasAttachments": false,
            "extent": {
                "xmin": -13090714.767112788,
                "ymin": 3841739.0914657288,
                "xmax": -12922032.654624918,
                "ymax": 3962581.2727843975,
                "spatialReference": {
                    "wkid": 102100,
                    "latestWkid": 3857
                }
            },
            "objectIdField": "FID",
            "fields": [
                {
                    "name": "FID",
                    "type": "esriFieldTypeOID",
                    "actualType": "int",
                    "alias": "FID",
                    "sqlType": "sqlTypeInteger",
                    "length": 4,
                    "nullable": false,
                    "editable": false,
                    "domain": null,
                    "defaultValue": null
                },
                {
                    "name": "CATEGORY",
                    "type": "esriFieldTypeString",
                    "actualType": "nvarchar",
                    "alias": "CATEGORY",
                    "sqlType": "sqlTypeNVarchar",
                    "length": 40,
                    "nullable": true,
                    "editable": true,
                    "domain": null,
                    "defaultValue": null
                }
            ]
        }
    ]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 24 Apr 2023 18:33:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1281995#M4466</guid>
      <dc:creator>LNX</dc:creator>
      <dc:date>2023-04-24T18:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1350925#M4614</link>
      <description>&lt;P&gt;I'm having a similar but slightly different experience trying to add an index to a hosted feature layer in ArcGIS Enterprise v11.1.&amp;nbsp; I've walked through the trial-and-error exercise of:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Get the original feature layer definition from &lt;A href="https://community.esri.com/" target="_blank"&gt;https://&amp;lt;MY-HOSTING-SERVER-HOSTNAME&amp;gt;/&amp;lt;WEB-ADAPTOR-NAME&amp;gt;/rest/admin/services/Hosetd/&amp;lt;SERVICE-NAME&amp;gt;/FeatureServer/0?f=json&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Modify it to:&lt;UL&gt;&lt;LI&gt;remove existing indexes&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;add the indexes I want to add&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Attempt to make the change with&amp;nbsp;&lt;A href="https://community.esri.com/" target="_blank"&gt;https://&amp;lt;MY-HOSTING-SERVER-HOSTNAME&amp;gt;/&amp;lt;WEB-ADAPTOR-NAME&amp;gt;/rest/admin/services/Hosetd/&amp;lt;SERVICE-NAME&amp;gt;/FeatureServer/0&lt;/A&gt;/addToDefinition&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;From here I went through several iterations of "Field &amp;lt;FIELD-NAME&amp;gt; cannot be updated".&amp;nbsp;&lt;EM&gt; I stripped out everything except "fields": [] and&amp;nbsp;"indexes": []&lt;/EM&gt;&amp;nbsp;(leaving out the existing indexes) and got past the&amp;nbsp;"Field &amp;lt;FIELD-NAME&amp;gt; cannot be updated" errors, but am now getting the error:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ERROR: "&amp;lt;SERVICE-NAME&amp;gt;_evw" is not a table or materialized view&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The '&amp;lt;SERVICE-NAME&amp;gt;_evw' appears in the original layer definition in the adminLayerInfo.viewName object, but adminLayerInfo was stripped out of the JSON posted to addToDefinition in order to get past the "Field &amp;lt;FIELD-NAME&amp;gt; cannot be updated" errors.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;At the end of the day I just want to add indexes to this layer.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 16:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1350925#M4614</guid>
      <dc:creator>ChrisBeaudette</dc:creator>
      <dc:date>2023-11-17T16:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1381727#M4668</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/557131"&gt;@LNX&lt;/a&gt;&amp;nbsp;not sure if you will see this message but you saved my day! I was struggling with the same and this works!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 18:00:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1381727#M4668</guid>
      <dc:creator>LorenzoPeve</dc:creator>
      <dc:date>2024-02-13T18:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1381794#M4669</link>
      <description>&lt;P&gt;I found some additional info as well that might help, in particular the reason behind the &lt;STRONG&gt;ERROR: "&amp;lt;SERVICE-NAME&amp;gt;_evw" is not a table or materialized view&lt;/STRONG&gt;. My feature service had 4 views created from it, all of which had editing and sync enabled. To get past the error we had to turn sync off for all views and the feature service itself. Once done we were able to add indexes.&lt;/P&gt;&lt;P&gt;CAUTION:&amp;nbsp; When disabling sync for FS + views the feature service got into an unstable state where the data was not rendering in the Data tab of the FS until we bounced the data store.&amp;nbsp; (Oddly the data showed up for the views that were created from the parent feature service, but not the feature service itself).&amp;nbsp; We ended up having to rebuild the feature service from scratch.&amp;nbsp; So as always, MAKE A BACKUP BEFORE YOU START! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 19:11:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1381794#M4669</guid>
      <dc:creator>ChrisBeaudette</dc:creator>
      <dc:date>2024-02-13T19:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1563167#M4891</link>
      <description>&lt;P&gt;Thanks for this post! I looked at it many times.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anywhere that shows all the inputs for the&amp;nbsp;&lt;STRONG&gt;addToDefinition&amp;nbsp;&lt;/STRONG&gt;payload? i.e. &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service/#example-usage" target="_self"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/add-to-definition-feature-service/#example-usage&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been able to get this work but I'm not sure what all the values are doing, and which ones are required and can't find this anywhere.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2024 21:27:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1563167#M4891</guid>
      <dc:creator>chris_del101</dc:creator>
      <dc:date>2024-11-27T21:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: AddToDefinition not working in Portal</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1582325#M4936</link>
      <description>&lt;P&gt;How do I change the name using &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/update-definition-feature-service/#example-four-update-feature-service-properties" target="_self"&gt;updateDefinition&lt;/A&gt;? When I try to I get:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt; "message": "Field 'name' cannot be updated.",&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 16:51:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/addtodefinition-not-working-in-portal/m-p/1582325#M4936</guid>
      <dc:creator>chris_del101</dc:creator>
      <dc:date>2025-02-05T16:51:28Z</dc:date>
    </item>
  </channel>
</rss>

