Hello,
I'm trying to save a webmap to my portal but I get the error below when trying to save it.
Error: The item does not exist yet and cannot be updated
I've tried both the update and save new code and neither works. My sample code is below.
I have tried both a dynamic and hard coded link.
// item automatically casts to a PortalItem instance by saveAs
const l_title = document.getElementById("webMapTitle");
const item = {
title: l_title.value
};
//// Setting authMode to immediate signs the user in once loaded
//portal = new Portal();
//portal.authMode = "immediate";
//// Auto should sign you in automatically
//portal.authMode = "auto";
// Update properties of the WebMap related to the view.
// This should be called just before saving a webmap.
//portal.load().then(function () {
map.updateFrom(view).then(() => {
map.saveAs(item)
// Saved successfully
.then((item) => {
// link to the newly-created web scene item
const itemPageUrl = `${item.portal.url}/home/item.html?id=${item.id}`; //OG itemPageURL setting
//const itemPageUrl = "https://www.arcgis.com/home/item.html?id=a24a038265eb4f3584451292c70d68ad"
const link = `<a target="_blank" href="${itemPageUrl}">${l_title.value}</a>`;
alert("Successfully saved as <i>${link}</i>");
})
// Save didn't work correctly
.catch((error) => {
if (error.name != "identity-manager:user-aborted") {
alert("Error: " + error.message);
}
});
});
I've also tried the to save using a portal also
////Save a new Webmap
portal.load().then(() => {
map.updateFrom(view).then(() => {
map.saveAs({
title: l_title,
portal: portal
});
});
});
Can anyone provide a working example of how to save to one's portal or get the portal to queue a log in window for me to authenticate? It works when I query portal items, but now when I try to save maps. The sanbox works on the ESRI server, but not in my local code.
Any help is appreciated, thank you!