|
POST
|
Huh, go figure. It may have been running all along, I'm unsure. In my latest code, I made a couple of little tweaks to my requestparams. It is instead: var requestParams = {
method: "post",
query: {
f: 'json',
username: 'MyUsername',
password: 'MyPassword',
client: 'requestip'
}
}; And added the token to my url, at the end. In any case, I'm still getting the signin screen, which I believe is because I'm calling the job wrong (at the moment I'm just using a window.open to call the url), but the job still calls and executes. I just assumed it wasn't because of the login screen. Now to find a better way to call the job... (eventually, because now other tasks have popped up)
... View more
10-17-2022
09:12 PM
|
0
|
0
|
766
|
|
POST
|
Sure. Sorry I've only just gotten round to this now, been in the field a bit. See below for the edited version: var tokenUrl = "https://myserver.com/portal/sharing/rest/generateToken";
var requestParams = {
method: "post",
query: {
f: 'json',
username: 'MyUsername',
password: 'MyPassword',
referer: window.location.origin
}
};
var myRequest = esriRequest(tokenUrl, requestParams);
myRequest.then(function(response){
var token = response.data.token;
esriId.registerToken({
server: "https://myserver.com/portal/sharing/rest",
token: token
});
initMap();
}); As I say, I have a tool which I can call using the following: https://myserver.com/server/rest/services/MyPrintLayouts/ScriptX01_AGP2_9/GPServer/ScriptX01/submitJob?&MyId=%7B<MyIdAsGUID>%7D&FileDestination=C%3A%5Ctemp%5C%7B<MyFilename>%7D.pdf&env%3AoutSR=&env%3AprocessSR=&returnZ=false&returnM=false&returnTrueCurves=false&context=&f=html If I'm logged into the server already, then it works fine. If I'm not however, I get presented with a login screen. I'd like to be able to use the token to access it, which doesn't seem to work if I include it in the URL (which I assume I'm doing wrong).
... View more
10-17-2022
08:37 PM
|
0
|
0
|
767
|
|
POST
|
I have a scripting tool on my Portal which works fine if the user is signed in. However, if the user is not signed in, the scripting tool obviously doesn't work. I also have a token, which has been generated earlier (though not much earlier - the token is still current). Is it possible to use this token to run my scripting tool, and if so, how should it be passed into the URL? This is a very basic version of how it works: window.open("https://myserver.com/server/rest/services/MyPrintLayouts/ScriptX01_AGP2_9/GPServer/ScriptX01/submitJob?Id=" + vId + "&FileDestination=" + vDestination + "&env%3AoutSR=&env%3AprocessSR=&returnZ=false&returnM=false&returnTrueCurves=false&context=&f=html", '_blank'); I've tried adding a &token=" + token Extra token parameter in there but that's not working. Each time it gets called, if the user isn't signed in, it will go to the sign in screen.
... View more
10-06-2022
10:08 PM
|
0
|
3
|
835
|
|
POST
|
I'm trying to set up and use a folder data store, so that I can access a layout.pagx file stored on my server in code (specifically, in ConvertWebMapToArcGISProject). ArcPy code should be something like this: templatePath = "\\myserver.com\server\LayoutStorage"
templateFile = "layout.pagx"
templateFull = os.path.join(templatePath, templateFile)
result = arcpy.mp.ConvertWebMapToArcGISProject(data, templateFull) Where LayoutStorage is the name of my folder data store, and layout.pagx is my layout file (see convertwebmaptoarcgisproject and data-store-items) Now, I don't think I've set this up correctly. The folder I've set up to be my data store is located on the server, simply at C:\Datastore_Layouts. In here there is the layout.pagx file (so C:\Datastore_Layouts\layout.pagx). The folder is shared with the ArcGIS user accounts. The data store item, in my Portal, has been set to address the \\localhost\Datastore_Layouts folder. This has been validated. It can be accessed by my https://myserver.com/server server (with a green tick next to it for status). However, I keep getting: RuntimeError: Missing or invalid layout template file. I must say though that, for testing purposes, I am doing this on my local install of ArcGIS Pro (and not on the server machine). Any help would be greatly appreciated - this is (hopefully) the last thing I need to get on this. Either that, or if there is a way to address a layout.pagx file from the existing Portal?
... View more
10-03-2022
10:22 PM
|
0
|
0
|
1201
|
|
POST
|
That's definitely some useful code. However, my code *was* working, but my code hadn't been put together well. I was trying to address a layer which didn't exist because I hadn't given it a title in the json I'm putting the webmap together with.
... View more
10-03-2022
08:56 PM
|
0
|
0
|
1334
|
|
POST
|
I'm trying to narrow down a layer using the lyr.definitionQuery = ... method, as below: result = arcpy.mp.ConvertWebMapToArcGISProject(data, templateFull)
aprx = result.ArcGISProject
#get the map, layer, apply the definition query
m = aprx.listMaps()[0]
lyr = m.listLayers("MyLayer")[0]
lyr.definitionQuery = "GUIDId = '" + RequestedGUIDId + "'" Now, this works fine if I do it using my current project on my computer, with everything loaded locally (so I don't have to bother with the ConvertWebMapToArcGISProject). However, we're trying to implement this online, so we have to get a json containing the layers we need and convert it to a project in the code. Now, for some reason, the lyr.definitionQuery line is not working - or more rather, it's having no effect. No matter what, it always returns the same number of features, which is odd (as my layer contains about 20,000 features - yet it always returns 151, even if I enter different values, or even values that don't exist!). The layer does support definition queries (I've tested that), and it definitely recalls the definition query (I've given it a delay after the definition query is set, and checked it by outputting). It's getting set, but for some reason the layer isn't paying any attention to it.
... View more
09-29-2022
11:04 PM
|
0
|
2
|
1377
|
|
POST
|
I've got a layout file that I've copied to my Portal. The layout refers to a webmap (which contains a few layers). My intention is to print the layout, zoomed to a certain extent (which I'd pass through to it), and only showing certain features (which, again, I can pass to it, or provide in a definition query). How would I accomplish this? I managed it using a local project, but now I'm trying to do it via Portal and have to use the arcgis.gis module. I've got code that will log in to the Portal and get the required extent, so just need to know how to interact with the layout. My code, so far, is below: import arcpy, os, sys
from arcgis.mapping import WebMap
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
#get variables
RequestedId = arcpy.GetParameterAsText(0)
cUN = arcpy.GetParameterAsText(1)
cPW = arcpy.GetParameterAsText(2)
#connect
gis = GIS(r"https://mydomain/portal", cUN, cPW)
#try and load the webmap
wm_item = gis.content.get("WebMapId")
wm = WebMap(wm_item)
#try to access the layer
for lyr in wm.layers:
if lyr.title == "MyLayer":
#convert it into a feature layer for local use
flayer = FeatureLayer(lyr.url)
###some handy old code, no longer used
###for f in flayer.properties.fields:
### arcpy.AddMessage(f['name'])
#grab the extent
MyExtent = flayer.query(where="Id='" + RequestedId + "'", return_extent_only=True)
#now we're going to need our layout
lyt_item = gis.content.get("MyLayoutId")
arcpy.AddMessage(lyt_item) For reference, this was my original code, which worked fine using a local project. Basically, I'd like to replicate this: import arcpy
#select our current map, and then the layer we want, and grab our Id from parameters
aprx = arcpy.mp.ArcGISProject("CURRENT")
RequestedId = arcpy.GetParameterAsText(0)
m = aprx.listMaps("MyWebMap")[0]
lyr = m.listLayers("MyLayer")[0]
#set our definition query
lyr.definitionQuery = "Id = '" + RequestedId + "'"
#define our extents
extents = []
#loop through and add our shape extent
with arcpy.da.SearchCursor(lyr,'SHAPE@') as cursor:
for row in cursor:
if row[0]:
extents.append(row[0].extent)
#get our actual extent
eXMin = min([ext.XMin for ext in extents])
eXMax = max([ext.XMax for ext in extents])
eYMin = min([ext.YMin for ext in extents])
eYMax = max([ext.YMax for ext in extents])
#now go into the layout
lyt = aprx.listLayouts("Layout")[0]
mf = lyt.listElements("mapframe_element", "WEBMAP_MAP_FRAME")[0]
mf.map = m
myExtent = arcpy.Extent(eXMin, eYMax, eXMax, eYMin, 0, 0)
mf.camera.setExtent(myExtent)
mf.camera.scale = mf.camera.scale * 1.1
m.defaultCamera = mf.camera
lyt.exportToPDF("C:\\temp\\mylayout.pdf") I've seen some things saying that you need to know where in the DataStore the layout is saved, but I can't find any way to find this out.
... View more
09-27-2022
11:27 PM
|
0
|
0
|
776
|
|
POST
|
Great, that works. My code is now: import arcpy, os, sys
from arcgis.mapping import WebMap
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
#get variables
RequestedId = arcpy.GetParameterAsText(0)
cUN = arcpy.GetParameterAsText(1)
cPW = arcpy.GetParameterAsText(2)
#connect
gis = GIS(r"https://mydomain/portal", cUN, cPW)
#try and load the webmap
wm_item = gis.content.get("webmapid")
wm = WebMap(wm_item)
#try to access the layer
for lyr in wm.layers:
if lyr.title == "MyLayerTitle":
#convert it into a feature layer for local use
flayer = FeatureLayer(lyr.url)
###some handy old code, no longer used
###for f in flayer.properties.fields:
### arcpy.AddMessage(f['name'])
#grab the extent
MyExtent = flayer.query(where="Id='" + RequestedId + "'", return_extent_only=True)
... View more
09-27-2022
11:17 PM
|
0
|
0
|
2347
|
|
POST
|
I'm currently trying to create a script which will do a few things, including loading a webmap, filtering it based on a definition query, zooming to the resulting shape extent, and then creating a PDF using a custom layout. I've managed to do all this using a local project in ArcGIS Pro, but had trouble exporting it (mainly because I was using the "CURRENT" project, and I'm now trying to do this via the Portal). In any case, I'm having to redo a fair bit of code. I'm getting stuck where I refer to the layer so I can perform a definition query on it. Basically, I'd ideally like the lyr object to refer to a layer, so I can do a "lyr.definitionQuery = etc" This is what I've got so far. I know the syntax is wrong, I'm just looking for the right one: import arcpy
from arcgis.mapping import WebMap
from arcgis.gis import GIS
#get variables
RequestedId = arcpy.GetParameterAsText(0)
cUN = arcpy.GetParameterAsText(1)
cPW = arcpy.GetParameterAsText(2)
#connect
gis = GIS(r"https://mydomain.com/portal", cUN, cPW)
#try and load the webmap
wm_item = gis.content.get("webmap_id_here")
wm = WebMap(wm_item)
#try to access the layer
arcpy.AddMessage(wm.layers)
lyr = wm.layers("ThisIsMyLayersTitle")[0] For reference, and probably to see more what I'm trying to do, this is my full (old) code that works on a local project: import arcpy
RequestedId = arcpy.GetParameterAsText(0)
#select our current map, and then the layer we want, and grab our Id from parameters
aprx = arcpy.mp.ArcGISProject("CURRENT")
RequestedForestId = arcpy.GetParameterAsText(0)
m = aprx.listMaps("MyWebMap")[0]
lyr = m.listLayers("MyLayer")[0]
#set our definition query
lyr.definitionQuery = "Id = '" + RequestedId + "'"
#define our extents
extents = []
#loop through and add our shape extent
with arcpy.da.SearchCursor(lyr,'SHAPE@') as cursor:
for row in cursor:
if row[0]:
extents.append(row[0].extent)
#get our actual extent
eXMin = min([ext.XMin for ext in extents])
eXMax = max([ext.XMax for ext in extents])
eYMin = min([ext.YMin for ext in extents])
eYMax = max([ext.YMax for ext in extents])
#now go into the layout
lyt = aprx.listLayouts("Layout")[0]
mf = lyt.listElements("mapframe_element", "WEBMAP_MAP_FRAME")[0]
mf.map = m
myExtent = arcpy.Extent(eXMin, eYMax, eXMax, eYMin, 0, 0)
mf.camera.setExtent(myExtent)
mf.camera.scale = mf.camera.scale * 1.1
m.defaultCamera = mf.camera
lyt.exportToPDF("C:\\temp\\mylayout.pdf")
... View more
09-26-2022
11:34 PM
|
0
|
2
|
2415
|
|
POST
|
Hi all I've got a Portal which has some secure content behind it. I'm currently able to access it via Azure Active Directory SSOs and an OAuth2 app, all through ESRI JS, which is great, works perfectly etc. However, we're building an environment in Dynamics 365. That doesn't seem to want to work with the OAuth2 app. Our developers tell me that the "code" and "state" parameters being returned with the redirect URI are invalid. So, a few questions if I may. First off, has anyone come across anything like this before, and is there a way (in anything, really) to fix it? Secondly, alternatives. Now, from the first reply on this topic (https://community.esri.com/t5/arcgis-enterprise-questions/unable-to-generate-tokens-using-saml-enterprise/m-p/1055538) which reads: When using an external identity provider via either SAML or OpenID Connect, Portal for ArcGIS (as the service provider) has no connection to the user's credentials. The authentication process is handled by the return of the properties within the SAML assertion/response and mapped to appropriate values within the Portal user's profile. With that being the case, token generation at the Sharing/REST endpoint is not possible for those users and would need to be generated via the OAuth2 mechanism. It seems we can't simply grab the username/password and feed it in to get a token, as they're all Azure AD users. Indeed, I've tried logging in through the login screen using my Azure AD username/password, and this doesn't work. Integrated Windows Authentication wouldn't work as we anticipate contractors using this too from outside our organisation. At the moment the only access I can see is having read-only credentials hard-coded in, which we really don't want to do. Does anyone have any ideas that would help? Thanks! EDIT - also, any way to remove these code and state parameters from the returned response (if they're not necessary)?
... View more
09-11-2022
10:39 PM
|
0
|
0
|
878
|
|
POST
|
I'm using an ArcGIS Enterprise install, meaning we have our own server with "server" and "portal" webadaptors on one of our machines, which will serve our data. Our users go onto this and can sign on using a single sign on with Azure AD. They've been using this, along with an OAuth2 app, to sign in securely and view our data, and we've got various controls set up using ESRI JS. Unfortunately, a change in software has meant we cannot use the OAuth2 app any more, and the only way I can see of doing what we need is to use tokens. I've tried to make sense of this, but I'm struggling to find many good samples of what I want. I've gone into our Server Manager and copied out the Shared Key, but now I don't know what to do.
... View more
09-08-2022
11:34 PM
|
0
|
1
|
749
|
|
POST
|
I've set up a Portal using ArcGIS Enterprise, which is working well, and am creating our own web maps in it. For our customer front-end, we would like to embed maps into the page using ESRI JS. Is it possible to create an API key so we can access our Portal's web maps? Currently, the only way I can see any API key seems to be using my developer account, which gives me an API key for my ArcGIS Online content. Is there a way to either create a new API key for my Portal, or to enable the existing API key to use my Portal content too?
... View more
08-09-2022
03:36 PM
|
0
|
1
|
1684
|
|
POST
|
I've created an ArcGIS Enterprise install (server, portal, two webadaptors, datastore, all on the same machine) and have just tried publishing a webmap to it from ArcGIS Pro. This worked fine. However, when I come to access it, I'm getting this error: Does anyone have any idea for this one? Obviously it's pointing at certificates, and I believe they're all set up (it's pointing to my machine.domain.com as the CN - so that would be without a https:// or port). One thing I am thinking is this could be because I've got a hyphen in the machine name (also in the domain, but looking at the GET requests the domain is being substituted for something else), and a few posts I've looked at indicate that ArcGIS Server doesn't like having numbers in the machine/domain. I wonder if it's the same for hyphens... EDIT - incidentally, I'm just looking at my certification path and noticed that I've got two certificates above mine. Would these both need to be imported into Portal (and whatever else)? If so, where would they need to go?
... View more
07-28-2022
09:16 PM
|
0
|
1
|
1096
|
|
POST
|
That's worked pretty well, thanks. And somehow I can access it on my server machine too!
... View more
07-28-2022
07:13 PM
|
0
|
0
|
1071
|
|
POST
|
I've just installed ArcGIS Enterprise using the Enterprise Builder - so this comes with ArcGIS Server, Portal, two webadaptors (server and portal), and Datastore. I can access Portal just fine using the credentials that I was asked for during the install, however I cannot access the Server Manager. I keep getting an "Unauthorized access" message, as below: Anyone got any ideas? This is the last part in this (very long) saga I feel, as I just need to get into Server Manager and register my data source.
... View more
07-26-2022
08:49 PM
|
0
|
2
|
1197
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-23-2023 10:56 PM | |
| 1 | 07-25-2022 10:50 PM | |
| 1 | 07-27-2021 08:16 PM | |
| 1 | 07-27-2021 10:44 PM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|