I've returned to a project where I'm managing Feature Services/Layers through the ArcGis REST JS and consuming the data via a web frontend using the ArcGis Maps Javascript SDK authenticated with a Api Key.
After I create a Feature Service (using createFeatureService) and a Feature Layer (using addToServiceDefinition) I want to add the Feature Service to my Api Key programmatically so I can access it from my web frontend.
When I did this the first time (around 2022) I used the, now legacy, Api Key and connected my Feature Service to the Api Key using addItemRelationship. But now with the new (application) Api Key this doesn't seem to work. How is this done with the new Api Key type? I tried to use updateItem, but couldn't get it to work. Does anyone have any advice?
Another thing I noticed is that when I manually add an item to the Api Key via "Edit Item Access" in the Online portal, the API Key for the "Application" disappears and I have to generate a new Api Key. Is this how it is supposed to work?