Select to view content in your preferred language

Feature layer added to Feature Service does not show in AGOL

6018
18
Jump to solution
06-15-2022 01:53 PM
MarkC1
by
Frequent Contributor

I've added a new feature layer to an existing feature service via the REST API (Add to Definition). The new feature layer gets added successfully and it is listed in the layers when viewing the service via the service URL. However, the layer does not appear in AGOL and I cannot access it. 

I've tested it with several existing feature services in my agol, by adding the exact same layer definition to multiple feature services. Some of for some of them it works perfectly but for others I get the above behaviour.  I have even tried to duplicate one of the existing layers in the feature services where I see this issue with no success.

Has anyone experienced this or can provide any help? I am guessing that there is something different about the layers it does not work on.

Edit: It seems to affect feature services originally published from Arcgis Pro

Example:

Point Layer 2 added via to existing layer via REST API. Visible at feature service URL but not showing up in AGOL

MarkC1_1-1655326316396.png

MarkC1_2-1655326365138.png

18 Replies
mikaël
Frequent Contributor

I talked to ESRI support about this and they finally told me it was a known bug: https://support.esri.com/fr-fr/bug/new-layers-added-to-a-service-via-the-rest-endpoint-do-bug-000145...

If you need to add the layer/table to a map, you can do it manually as explained at the bottom of the bug page.

0 Kudos
BRENNEJM
Regular Contributor

For anyone else that finds this page and tries to follow the work around instructions for BUG-000145205, the instructions on that page are not correct. Those instructions have you create a new hosted feature layer (which defeats the purpose of using "Add to Definition"). Correct instructions below:

  • Open the hosted feature layer page that you added a new layer to
  • Click on any of the layers shown in the "Layers" section
  • Within that page on the right side, find and copy the rest service URL
  • Open the map you want to add the new layer to in map viewer
  • Go to Add > Add layer from URL
  • Paste the URL in the URL box ("ArcGIS Server web service" should get selected by default)
  • In the URL, change the ending number to the layer ID of the new layer you added
  • Click on Next
  • The layer should now be visible in the map
0 Kudos
ANRGIS
by
Frequent Contributor

Hello,

I was successful testing this on a newly created hosted feature layer but when I try and add it to my production hosted feature layer I get this message:

{
  "error" : 
  {
    "code" : 400, 
    "message" : "Unable to add feature service definition.", 
    "details" : [
      "Incorrect syntax near the keyword 'on'."
    ]
  }
}

I ran the JSON through Lint and it was valid. Any insight on why?

The hosted feature layers are deployed from an ARCGIS Solution and there's bunch of existing layer and tables.

 

 

 

0 Kudos
mikaël
Frequent Contributor

What are you sending?


"Incorrect syntax near the keyword 'on'."


Seems to me like it's something you're sending to the API.

0 Kudos
ANRGIS
by
Frequent Contributor

Yep. It's JSON for adding a new layer using the addToDefinition parameter like @MarkC1 outlines. Works for newly created layer but not the one I want.

0 Kudos
mikaël
Frequent Contributor

Are you sure you are in the right thread? This is for successfully sent data through the API where the layer/table appears afterwards when querying the API but does not show on the AGOL interface.

Anyway, check what you are sending to the API and search for "on" as is suggested in your error message. Possibly a SQL query?

0 Kudos
ANRGIS
by
Frequent Contributor

You're right, not exactly the right thread but the thread has best explanation executing the add layer definition. "on" shows up about a hundred times, I don't think the error is helpful in this case. Thanks

0 Kudos
AvinashDalvi_
Occasional Contributor

How to upload file while using AddToDefination API ? 

0 Kudos
MitchellGrafstein
Frequent Contributor

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
0 Kudos