I am trying to add an extra layer to a hosted feature layer. I dont find any function inside AGOL to do it directly and I have tried some code in Notebook, but it doesnt seem to be possible. Any ideas how I can do this?
See screenshot
Thanks!
Solved! Go to Solution.
You can add new layers to a hosted feature layer using the "add to definition" function of the REST API and Python API.
I would definitely test this out on a layer you don't care about first though, especially if you're adding any kind of relationships, it's very easy to mess this up and can be difficult to fix.
Another option would be to export your existing HFL to a File GDB, add a new feature class to the GDB in Pro, then republish the modified File GDB as a new HFL. This option is definitely safer and easier but can be more work if you have web maps and apps hanging off your existing HFL.
I've been working on this too. There is a real need for it since we can't see the future or anticipate all needs of a layer at initial creation. Even ESRI Solutions need extended and they seem to include even the kitchen sink. Here's the best post I've found that even has info about a github repo with samples and a bug that shows a workaround to getting these newly added items to show in portal after adding them through the REST API.
You can add new layers to a hosted feature layer using the "add to definition" function of the REST API and Python API.
I would definitely test this out on a layer you don't care about first though, especially if you're adding any kind of relationships, it's very easy to mess this up and can be difficult to fix.
Another option would be to export your existing HFL to a File GDB, add a new feature class to the GDB in Pro, then republish the modified File GDB as a new HFL. This option is definitely safer and easier but can be more work if you have web maps and apps hanging off your existing HFL.
How can i get a token to access the rest api? Its says token required
If you go through Portal/ArcGIS Online to the Item Overview page and scroll down to the "URL" link, it will open it up in the rest services directory and then you can click "Admin" in the upper right. This window has the token already applied. Use the links at the bottom to "addToDefinition". Also, if it says that the token is expired, refresh the Overview page and repeat those steps.
this is what i see
Nevermind. I managed. thanks! 🙂
My problem now is that the layer doesnt appear and I can't create a new item. I get an error...do you know a code to add data that works?
How a regular user can do this via ArcGIS PRO (no APY)?
I've been working on this too. There is a real need for it since we can't see the future or anticipate all needs of a layer at initial creation. Even ESRI Solutions need extended and they seem to include even the kitchen sink. Here's the best post I've found that even has info about a github repo with samples and a bug that shows a workaround to getting these newly added items to show in portal after adding them through the REST API.