|
POST
|
Just edited my answer above, but yeah, the MapServer data is secured as well as one other GP service than the one already mentioned, so that's why I'm getting a login page for the whole map now. I could turn security off for those services and just leave the one aformentioned GP service secured and see what happens.
... View more
10-23-2018
12:02 PM
|
0
|
9
|
2414
|
|
POST
|
Have added it. Now prompting me to log in to view the data on the map, so it's still not generating a token for some reason. <ProxyConfig allowedReferers="https://www.mydomain.com/*"
mustMatch="true"
logFile="proxyLog.txt"
logLevel="Warning">
<serverUrls>
<serverUrl url="https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement"
username="username"
password="password"
matchAll="true"/>
<serverUrl url="https://www.mydomain.com/appName/HabitatMap/HabitatJSMap"
password="username"
password="password"
matchAll="true" />
</serverUrls>
</ProxyConfig> Getting a 404 Resource Not Found error. I wonder if it's because I have a relative path as my proxy path? It says this, so that might be it: <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. <br><br> <b> Requested URL: </b>/proxy/proxy.ashx<br><br> The URLs it's trying to place a request with also are off: https://www.mydomain.com/proxy/proxy.ashx?https://www.mydomain.com/myServer/rest/services/… I wonder if I change the JS to this if it would work? Or may make the proxyUrl property an absolute path instead of relative. I will play around with it. //Set up the proxy to forward requests for data/geoprocessing tools
urlUtils.addProxyRule({
urlPrefix: "https://www.mydomain.com/appName/HabitatMap/HabitatJSMap",
proxyUrl: "/proxy/proxy.ashx"
});
... View more
10-23-2018
11:55 AM
|
0
|
11
|
2414
|
|
POST
|
Yes - you are correct. The "proxy" folder is located underneath my app folder. I have tried a new combination of Urls and now I'm getting a little closer... now I can access my services by going direct with the URL without having to login. I can see that it logs me in with the correct user that I have allowed access to the secured service. https://www.mydomain.com/appName/proxy/proxy.ashx?https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement This occurs when I use this configuration: //Set up the proxy to forward requests for data/geoprocessing tools
urlUtils.addProxyRule({
urlPrefix: "https://www.mydomain.com",
proxyUrl: "/proxy/proxy.ashx"
}); <ProxyConfig allowedReferers="https://www.mydomain.com/*"
mustMatch="true"
logFile="proxyLog.txt"
logLevel="Warning">
<serverUrls>
<serverUrl url="https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement"
username="username"
password="password"
matchAll="true"/>
</serverUrls>
</ProxyConfig> If I go to my service in the web map, it still wants me to login and gives me an error about the token being required in the POST request header. {"error":{"code":499,"message":"Token Required","details":[]}}
... View more
10-23-2018
11:35 AM
|
0
|
13
|
5081
|
|
POST
|
Nope. I had to switch to 3.24 a while back because 4.x didn't have file upload capabilities yet.
... View more
10-23-2018
10:31 AM
|
0
|
15
|
5081
|
|
POST
|
Thanks, just tried it, but it didn't do the job (going off the documentation for defaults.io syntax) esriConfig.defaults.io.proxyUrl = "https://www.mydomain.com/appName/proxy/proxy.ashx"
... View more
10-23-2018
09:52 AM
|
0
|
17
|
5081
|
|
POST
|
I have since tried setting the allowedRefers to a wildcard but still am having issues. The documentation states that I should be used the addProxyRule given that I am using a username and password: Using the proxy | Guide | ArcGIS API for JavaScript 3.26 Note: If you are storing login information (username and password or client_id and client_secret) in the proxy you will want to use the addProxyRule option so that requests to the resources with the specified URL prefix are routed through the proxy. If I change it to esriConfig.request.proxyUrl would it be equal to this? "/proxy/proxy.ashx" I am using the .NET installation of the proxy and the folder it sits in I have renamed as "proxy"
... View more
10-23-2018
09:35 AM
|
0
|
19
|
5081
|
|
POST
|
I'm quite confused on how to get this proxy working. I've secured one geoprocessing service called Habitat Management. It is located in the HabitatManagement folder, the service is titled HabitatManagement, and it contains a geoprocessing task called HabitatManagement. Essentially, the url for the secured service looks like this: https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement/GPServer/HabitatManagement The actual web mapping application resides inside of a .NET application. The URL of the .NET application is this: https://www.mydomain.com/appName The actual web map url is this: https://www.mydomain.com/appName/HabitatMap/HabitatJSMap I have my proxy config file set up like so: <ProxyConfig allowedReferers="https://www.mydomain.com/appName/*"
mustMatch="true"
logFile="proxyLog.txt"
logLevel="Warning">
<serverUrls>
<serverUrl url="https://www.mydomain.com/myServer/rest/services/HabitatManagement/"
username="username"
password="password"
matchAll="true"/>
</serverUrls>
</ProxyConfig> I have the proxy JS code like this: urlUtils.addProxyRule({
urlPrefix: "https://www.mydomain.com",
proxyUrl: "https://www.mydomain.com/appName/proxy/proxy.ashx"
}); If I go to the proxy page following this URL: https://www.mydomain.com/appName/proxy/proxy.ashx It works as expected, it says "Config File: "OK" Log File: "OK"" When I test this URL, it takes me to the HabitatManagement folder but does not show the services within it, even though the token should be passing the username and password so I can see the services, right? That's issue #1 that I don't understand. https://www.mydomain.com/appName/proxy/proxy.ashx?https://www.mydomain.com/myServer/rest/services/HabitatManagement Additionally, when I go the web map and try to access the service, it still makes me login with this message: Please sign in to access the item on https://www.mydomain.com/myServer (HabitatManagement/HabitatManagement) If I login, things work fine - it appears the token is generated and appended to the URL as it should be. If I change the config file serverURL to this (note the extra "HabitatManagement" on the end of the URL): <serverUrl url="https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement"
username="username"
password="password"
matchAll="true"/> and try this URL, the request fails with "Bad Request" error: https://www.mydomain.com/appName/proxy/proxy.ashx?https://www.mydomain.com/myServer/rest/services/HabitatManagement/HabitatManagement and if I test it in the application it still prompts me to login with the same message as before. I have also tried to change my serverURL to something very general with no luck. Ideally, the serverURL would be more specific than this as there are some services we have that don't require authentication thus do not need to run through a proxy. <serverUrl url="https://www.mydomain.com"
username="username"
password="password"
matchAll="true"/> I'm not sure if my proxy is located in the wrong spot, or if my referrer URL is messed up, or if my serverURLs are messed up. How do I access my secured services using the proxy?
... View more
10-23-2018
08:49 AM
|
0
|
29
|
11933
|
|
POST
|
The final URL should look like this...what I was missing was defining the task after you define what type of server you're trying to access: https://www.domain.com/serverName/myfolder/myservice/typeOfServer/task?<token> For example: https://www.blahblahblah.org/natureServer/HabitatManagement/HabitatManagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi **Note that I am using the above URLs with a web adapter installed so I can access my services directly from my domain. If you're not using a web adapter then it'd be something more like this: https://natureServer:6080/arcgis/HabitatManagement/HabitatManagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi To illustrate this further, from your main rest services page, your folders: If I click on HabitatManagement, I get taken to my services: If I click on that service, I get taken to my tasks Those make up the three parts of your URL. After you append the token to end of that (don't forget the question mark!) then it should log you in automatically and give you access.
... View more
10-22-2018
08:11 AM
|
1
|
1
|
3670
|
|
POST
|
So you're saying in the HTTP referrer field, I should be using https://www.domain.com/serverName/ ? Or would it be https://www.domain.com/serverName/myfolder/myservice/GPServer ? The domain our web app sits on and the token URL are the same domain, if that matters.
... View more
10-20-2018
05:15 AM
|
0
|
0
|
3670
|
|
POST
|
I'm messing around with securing my services and plan on putting in place token-based authentication for our JS API application. I'm just trying to get a handle on what tokens do and how they work. I have made a user in our ArcGIS server, assigned it the "User" role, and have set one service to only allow access by logged in users that are part of the "user" role. I went to generate a token at https://domain.com/serverName/tokens and filled that out to generate the token. I filled out the HTTP referer field as www.domain.com with the domain our JS API web app sits on. Now, when I try to access that service via the rest endpoint with the token, I get taken to a login page. Isn't the token supposed to automatically log me in and give me access to the service? If not, how is the token doing anything different than just going to services page and hitting "Login"? This is how I'm trying to access the service with the generated token: https://www.domain.com/serverName/rest/services/myfolder/myservice/GPServer?<token here> Am I misunderstanding what tokens do?
... View more
10-19-2018
11:01 AM
|
0
|
4
|
3939
|
|
POST
|
Sorry for the late response, hope you've figured it out by now, but if you haven't...it's been a while since I did this and I actually had to switch my app to 3.x as I was building it because 4.x is still missing some functionality I needed. I found this in my old code which has all the labels seen in my legend. Maybe that's what you need, to create a renderer with labels? //Define the UniqueValueRenderer for displaying quail habitat status var qhRenderer = { type: "unique-value", field: "OfficialQH", legendOptions: { title: "Quail Habitat Status" }, uniqueValueInfos: [{ value: 0, symbol: { type: "simple-fill", color: [225, 225, 225], outline: { color: "black", width: 1 } }, label: "Not Quail Habitat" }, { value: 1, symbol: { type: "simple-fill", color: "green", outline: { color: "black", width: 1 } }, label: "Quail Habitat" }] };
... View more
10-19-2018
05:55 AM
|
1
|
1
|
6339
|
|
POST
|
So it turns out using conditionals isn't possible when formatting popup content as per the documentation: Placeholders (string substitution) When graphics or feature layers have an info template, that info template is automatically used by the API to construct info window content when a feature is selected. Within an info template, placeholders denoted by ${} are used to specify attributes to display. At run-time, substitution occurs and the placeholder is replaced with the actual attribute value for the selected feature. In the code below, values inside ${} correspond to attribute field names. In the screen shot, values for the selected feature were substituted for the associated placeholders. Since it doesn't actually convert the values until run time, that's why it always appears as the placeholder when you console.log() it and never appears to change despite the function returning an actual value. To work around this, it appears I have to write a custom function and set the InfoTemplate content to what gets returned by the function. This means you don't use attribute fields specifiers and instead work with a graphic to get the attributes. Format info window content | Guide | ArcGIS API for JavaScript 3.25
... View more
09-04-2018
12:28 PM
|
0
|
0
|
1760
|
|
POST
|
Nah, that won't work. I am using API 3.25, I think the syntax might be a little different in 4.x. If I try what you suggested with the two console.log statements, it first prints 'null' and then it prints 'None' as I would expect. As I stated earlier, the functions are fine and work correctly, I just can't access the returned value through the variable they are returned to, for whatever reason. They print as I would expect in the popups, except for the fact that it ignores all the conditionals because the statements will never evaluate to true given the string being stored in the variable never updates/changes... The code generating this popup is pretty complicated given that the HTML is altered depending on what data was entered and what was left null by the user....but if you want to wade through it, be my guest, lol. //Format the popup content for the habitat management tract feature layer
var veg1 = '${VegMgmtPractice1:vegPName}';
var pcntTreat1 = '${PercentTreated1:pcntName}';
var month1 = '${Month1:monthName}';
var content = '<table id="mgmtPopupTable1"><tr><th>Veg Mgmt Practice</th><th>% Field Treated</th><th>Month Treated</th></tr> \
<tr><td>' + veg1 + '</td><td>' + pcntTreat1 + '</td><td>' + month1 + '</td></tr>';
var veg2 = '${VegMgmtPractice2:vegPName}';
if (veg2 != 'Did nothing') {
var pcntTreat2 = '${PercentTreated2:pcntName}';
var month2 = '${Month2:monthName}';
content = content + '<tr><td>' + veg2 + '</td><td>' + pcntTreat2 + '</td><td>' + month2 + '</td></tr>';
var veg3 = '${VegMgmtPractice3:vegPName}';
if (veg3 != 'Did nothing') {
var pcntTreat3 = '${PercentTreated3:pcntName}';
var month3 = '${Month3:monthName}';
content = content + '<tr><td>' + veg3 + '</td><td>' + pcntTreat3 + '</td><td>' + month3 + '</td></tr></table>';
}
else {
content = content + '</table>';
}
}
else {
content = content + '</table>';
};
var fbPractice = '${FarmBillPractice:fbPName}';
content = content + '<br><p class="mgmtPopupPgph"><b>Farm Bill Practice:</b> ' + fbPractice + '</p>';
if (fbPractice != 'None') {
var mcm1 = '${MCMPractice1:mcmName}';
if (mcm1 != 'None') {
var month4 = '${Month4:monthName}';
content = content + '<table id="mgmtPopupTable2"><tr><th>Mid-Contract Mgmt</th><th>Month Applied</th></tr> \
<tr><td>' + mcm1 + '</td><td>' + month4 + '</td></tr>';
var mcm2 = '${MCMPractice2:mcmName}';
if (mcm2 != 'None') {
var month5 = '${Month5:monthName}';
content = content + '<tr><td>' + mcm2 + '</td><td>' + month5 + '</td></tr></table>';
}
else {
content = content + '</table>';
}
}
else {
content = content + '</table>';
}
};
var herb1 = '${Herbicide1:herbName}';
if (herb1 != 'None') {
content = content + '<br><p class="mgmtPopupPgph"><b>Herbicides:</b> ' + herb1;
var herb2 = '${Herbicide2:herbName}';
if (herb2 != 'None') {
content = content + ', ' + herb2 + '</p>';
}
else {
content = content + '</p>'
}
};
var impBy = '${ImplementedBy:impName}';
var fundBy = '${FundedBy:fundName}';
content = content + '<p class="mgmtPopupPgph"><b>Implemented by:</b> ' + impBy + '<br><b>Funded by:</b> ' + fundBy + '</p>';
var mgmtTractPopupBox = new InfoTemplate("${StateID} Habitat Management Tract", content);
var mgmtLinePopupBox = new InfoTemplate("${StateID} Habitat Management Line", content);
... View more
09-04-2018
11:56 AM
|
0
|
0
|
1760
|
|
POST
|
I'm creating a custom pop-up where I send the attribute table value into a function to reformat it. It's called like so: var herbicide = '${Herbicide1:herbName}' It then enters the function like this (it has many more cases than what's shown): herbName = function(value){
herb = '';
switch(value){
case null:
herb = 'None';
break;
case 1:
herb = '2,4-D';
break;
....
};
return herb;
}; The 'return herb' line should return the new value and I thought that the 'herbicide' variable would be set equal to whatever was returned, but that does not appear to be the case if I actually try to print it's value. When I print it: >>> console.log(herbicide); >>> ${Herbicide1:herbName} This is making it really hard to do conditional statements on the variable. For instance, if herbicide is set to 'None' then I don't want it to show up in the popup, but using this statement: if (herbicide == 'None'){
//do something
} It will never evaluate true because unfortunately, no matter what value was returned from the function, the value being tested against is always the string '${Herbicide1:herbName}' What's weird to me is that you can't see the value by printing it to the console, yet I know my functions are returning the correct values because it prints them correctly to a popup. I can't test the value I need to test... what can I do to fix that?
... View more
09-04-2018
10:46 AM
|
0
|
3
|
1972
|
|
POST
|
I know it's not the ideal solution, but I've had a lot of success using Visual Studio as my main IDE. I got fed up with PyCharm and switched over - I don't miss PyCharm one bit.
... View more
08-31-2018
11:02 AM
|
0
|
0
|
4390
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2020 10:31 AM | |
| 2 | 09-16-2025 02:17 PM | |
| 3 | 09-12-2025 09:26 AM | |
| 1 | 08-16-2023 05:11 PM | |
| 1 | 02-27-2024 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-16-2025
02:16 PM
|