0

I am attempting a very basic script that loads a Portal WebMap using the Esri JS API. Here is the error message I am getting:

(index):146 [esri.WebMap] #load() Failed to load web map 
l
details:
error: l
details:
getHeader: V=>ya.headers.get(V)
httpStatus: 400
messageCode: "CONT_0001"
messages: []
raw: {code: 400, messageCode: 'CONT_0001', message: 'Item does not exist or is inaccessible.', details: Array(0)}
requestOptions: {authMode: 'auto', body: null, cacheBust: false, method: 'auto', query: {…}, …}
ssl: false
subCode: undefined
url: "https://www.arcgis.com/sharing/rest/content/items/c1127b4c1e3e4ab9bd3005192f6e6731"
[[Prototype]]: Object
message: "Item does not exist or is inaccessible."
name: "request:server"
[[Prototype]]: c
[[Prototype]]: Object
message: "Failed to load portal item"
name: "webmap:load-portal-item"
[[Prototype]]: c

Here is my JS script:

require(["esri/config","esri/views/MapView", "esri/WebMap"], 
  (esriConfig, MapView, WebMap) => {

  var esriConfig = {
    portalUrl: "https://domain/portal/home/",
  };

  const webmap = new WebMap({
    portalItem: {
      // autocasts as new PortalItem()
      id: "c1127b4c1e3e4ab9bd3005192f6e6731"
    }
  });

  const view = new MapView({
    map: webmap,
    container: "viewDiv"
  });
});

Here is my HTML script:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>Testing</title>
  <style>
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
  </style>
  <link 
  rel="stylesheet"
  href="https://js.arcgis.com/4.24/esri/themes/dark/main.css"
  />

</head>
<body>
  <div id="viewDiv"></div>
  <script src="https://js.arcgis.com/4.24/"></script>
  <script src="js/test_main.js"></script>

</body>
</html>
3
  • 2
    'Item does not exist or is inaccessible.' It's trying to access a webmap which doesn't seem to exist (see e.g. at arcgis.com/home/item.html?id=c1127b4c1e3e4ab9bd3005192f6e6731 ). Are you using ArcGIS Online or Enterprise for this webmap? Is it a public web map? Jul 25, 2022 at 21:02
  • I'm using Enterprise for the webmap and it's shared publicly. It seems to be directing me to argis.com instead of taking on my Portal domain... Jul 26, 2022 at 12:53
  • Does the network traffic show any requests to your enterprise? Maybe with some errors that makes it default back to ArcGIS Online? Jul 26, 2022 at 16:39

1 Answer 1

1

There are two way to specify the portalURL. Does it work if you change it from using the global esriConfig variable and instead do:

esriConfig.portalUrl = "https://domain/portal/";

https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html

1
  • 1
    I found out that adding the /home to the url was messing things up.... Aug 9, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.