Finally found this after searching a bit yesterday when this same issue came up, so thank you @MarkC1 and others for your efforts here.
Appreciate this thread alerting me to take a look at the service's Data JSON via ArcGIS Assistant.
{
"id": 3
},
{
"id": 4
},
{
"id": 5
}
The "id" in this case corresponds to the sublayer or table in the service. If you click on a layer or table in the web interface, or if you drill down into a layer or table via the REST pages, you will see this "sublayer" information. https://blahblah/name_of_service/0 <--- the '0' in this example.
I added two new tables to my service using the addToDefinition REST API (described here and elsewhere.) These tables did not show up in the data JSON. (Sublayers/tables with an ID of 6 and 7.)
I edited the DATA JSON and added in the missing IDs (under "tables" since I was adding tables.)
{
"id": 6
},
{
"id": 7
}
Doing the above added the two new tables back into the web interface which resolved my issue.
Few things to note - the "id" in this case corresponds to the sublayer/table in the item - these increment as you add them and normally start with layers and end in tables. So, if you had two layers and one table...
- Sublayer 0: Layer 0
- Sublayer 1: Layer 1
- Sublayer 2: Table 0
I hope this helps add to the discussion.
As a general rule of thumb for this whole process, and there are examples of using addToDefinition elsewhere and within this thread - I suggest creating a mock service with new layers/tables in AGOL/Enterprise or hosted via ArcGIS Pro. Use the REST Admin pages to copy the layer or table formatting for an individual layer and the beginning format for the "layers" or "tables" part of the object from the mock service. I do not believe you need the database section of the JSON - just the section starting with the new layer/table ID and the formatting for the "layers" or "tables" part of the JSON.
Also, always make sure you make a copy of the full Admin JSON on your existing service. We back these up from time-to-time, as well. I would suggesting backing up your service to FGDB, as well.
After adding the new layer/table to the existing definition, if the layer/table does not show up in the Overview page - edit the Data JSON using ArcGIS Assistant as above.
This whole process is not for the faint-of-heart. I find it extraordinarily easy to mismatch the formatting somewhere and not have the addToDefinition take or something else like this can occur even if you do everything correctly. If there is an enhancement to be able to add a new layer or table to an existing service in AGOL or Enterprise via the web interface, which also allows copying the schema from an existing layer or table, I would gladly upvote!
I hope this helps.
Mitchell Grafstein, Horticultural Inspector 1, NYS Dept. of Agriculture and Markets