This sample demonstrates how to save a WebMap to a Portal for ArcGIS item by creating a new item. Saving a web map is easy. All that’s required is a WebMap and a valid Portal to save the map to.
Saving to a new item
Create a new empty WebMap instance or load an existing web map in your application. To save an existing webmap as a new portal item call saveAs() method. This saves the web map to a new portal item. Saving will trigger user authentication, and if successful the item will be saved to the given Portal.
/************************************************************ * Creates a new WebMap instance. A WebMap can reference * a PortalItem ID that represents a WebMap saved to * arcgis.com or an on-premise portal. ************************************************************/const webmap = new WebMap({ portalItem: { id: "06ca49d0ddb447e7817cfc343ca30df9", },});
// Update properties of the WebMap related to the view.// This should be called just before saving a webmap.webmap.updateFrom(viewElement.view).then(() => { webmap .saveAs(item) .then((item) => { console.log("WebMap saved successfully"); }) // Save didn't work correctly .catch((error) => { console.error("Webmap did not save."); });});Please refer to the ArcGIS Organization portals for information on how the