Update Hosted Feature Layer - Update Definition has no editable JSON

1031
2
07-27-2020 03:39 PM
Henry
by
Occasional Contributor II

Hi all,

I am attempting to edit one of our organization's hosted feature layers through the Rest API. We have a hosted layer that needs to be updated to better match a new version of one of our Survey123 forms - specifically with the addition of several coded domain values.

I was using this blog for guidance: https://www.esri.com/arcgis-blog/wp-content/uploads/2014/10/How-to-Update-Hosted-Feature-Service-Sch...

However, within Update Definition, the input (where the editable JSON should appear) is totally blank. 

I also tried copying the JSON at the front of the rest URL, edited it, verified the JSON, but when I tried to paste it into the Input here with my changes and click 'updateDefinition' I received this error:

For my last attempt I used AGO-Assistant to view the layer's JSON and attempted to replace it with the updated JSON. But the changes did not register. The JSON presented in AGO was also shorter and missing much of the information from the JSON at the rest URL.

Our organization is currently using ArcGIS Portal and ArcGIS Enterprise, not AGOL, so I'm not sure if that could be a factor. At this point the simplest solution for me would be to make a local copy of the feature layer and overwrite it, but its being used in so many webmaps and customizations so that is really a last resort option for me.

Any thoughts as to why this could be happening? Workarounds?

Henry
0 Kudos
2 Replies
RandyBurton
MVP Alum

In my experience (only with AGOL), I only update sections.  In your case since you want to add additional domains, the section would be the fields section, and it would only contain the fields using the domain being changed.  This way, the things that cannot be changed, such as "allowGeometryUpdates", are not included.  I also do not include the "drawingInfo" section.  Since you are working with domains, the "types" section may need editing depending on the set up.

For example, to add the color Blue to a domain list, start with the comma on line 24 and add through line 28.  Then check it with something like jsonlint for valid json before updating.   Also, experiment on a backup of the service first.

{
	"fields": [{
		"name": "Color",
		"type": "esriFieldTypeString",
		"alias": "Point Color",
		"sqlType": "sqlTypeOther",
		"length": 1,
		"nullable": false,
		"editable": true,
		"domain": {
			"type": "codedValue",
			"name": "Colors",
			"codedValues": [{
					"name": "Red",
					"code": "1"
				},
				{
					"name": "Yellow",
					"code": "2"
				},
				{
					"name": "Green",
					"code": "3"
				},
				{
					"name": "Blue",
					"code": "4"
				}
			]
		},
		"defaultValue": null
	}]
}
Henry
by
Occasional Contributor II

Yes!

It was a little finicky but I was able to update the JSON with the new coded domains of the Hosted Feature Layer that I wanted. It showed up across my other webmaps and the associated Survey records the new values appropriately.

Strange that for many people using ArcGIS Enterprise the JSON does not seem to appear. I've read other comments on that issue. Hopefully it can be addressed in the future.

Thank you!

Henry
0 Kudos