Select to view content in your preferred language

Couple of questions about the API

5546
40
05-29-2014 07:48 AM
DanielMclaglen
Emerging Contributor
Hi Guys

I am very new to arcgs and have a couple of questions.

1. I am accessing a saved arcgs map using the call back for function createmap. I have added the basemap gallery to the map and this works and changes the base map without any problems. The only issue is that the basemap image gallery is not displaying the thumbnails. Are there any known issues with his?

2. Is there a way / widget for the layer selector that can be added?

3. Is there a way / widget for the search box?

4. Is there an example of passing the username and password to create map to avoid the authentication challenge. Have seen some posts about using OAuth but could not quite get that to work.

The map looks like attached

[ATTACH=CONFIG]34178[/ATTACH]

Ta,
D
0 Kudos
40 Replies
DanielMclaglen
Emerging Contributor
Oh jaysus my apologies John -- I just assumed you were a fellow user.

Ok so first question do I even need the application to be setup in ArcGIS online?
Second if I can authenticate using username and password then why would my basic map with no layers not work when using username and password?

Ta,
D

thats fine.  you can tell them you'd like to work with me specifically if you want 🙂

appId/appSecret should not be thought of as a way to authenticate and access shared content.  those credentials are specifically intended to allow an application to access subscription services which burn credits without requiring someone to sign in, or provide information to identify an app which uses an OAuth2 technique to have people sign in with their own credentials to work with private content.
0 Kudos
JohnGravois
Deactivated User
only 90% sure i understand the whole use case, but it sounds like registering the app and getting an appId and appSecret isn't doing anything for you here.

if you are exclusively trying to access a private webmap with private services, username/password for the secure items only in the proxy.config should be sufficient.

i don't think it would hurt to log a tech support ticket for this.  it might be easier to hash out over the phone anyway 🙂
0 Kudos
DanielMclaglen
Emerging Contributor
I have 2 private webmaps (one with layers and one without layers).

If I call the one without layers then this will load without a challenge provided I supply an AppID and a Secret. If I do not provide these in the proxy config then it will challenge even if I provide a username and password.

On the 2nd map which has layers which come from (https://service2.....) then it does not matter what I supply it will challenge every single time.

Not too sure how to log a ticket as only started working with the API a few days ago.

That is basically it,
D
0 Kudos
JohnGravois
Deactivated User
if you've paid for an associated product you can email support@esri.com or call 888.377.4575 with your customer number to log a new call requesting help with our javascript api.

in general, you need to forget about using appId/appSecret and figure out why username/password aren't sufficient when attempting to load a private webmap with only a single public basemap layer. 

most importantly, when you snoop the web traffic generated by your app, does the request to retrieve the JSON describing the webmap go through the proxy at all?
0 Kudos
DanielMclaglen
Emerging Contributor
I know the guys (a different department from IT) did pay for something although not sure what exactly. Basically this is a prove of concept app to integrate the map/s into a BI app.

Ok I am going bin the appid and secret completely and focus on what you have suggested. I have your proxy class part of my vs project so debugging I can see the requests are going via the proxy class.

I did make one change to the proxy class to authenticate with our proxy although I can't see why this would have an impact.
req.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
Currently got to do this as I have an issue with traffic not going via our proxy but once sorted I will bypass our network proxy completely.

Ta,
D
0 Kudos
JohnGravois
Deactivated User
my usual technique of snooping more deeply is to run the proxy in a custom application pool with my own credentials.  that way a tool like fiddler will capture not only the request 'to' the proxy, but also the request that the proxy itself is making.
0 Kudos
DanielMclaglen
Emerging Contributor
Hi John

Fiddler did indeed yield some interesting results.

1. It seems my network proxy is blocking some requests which is strange as I have added authenitication details and some requests do succeed. Not sure why this is but I will bypass the network proxy all together. This is going to take a few days as the my circuit for internet traffic not routed via the proxy is down and 3 days in and the ISP has no answers.

2. Some of the json returned is request not made over ssl. Not entirely sure how to resolve this?

Last question is when I have the map with layers that run on services2 then do I need an extra config section in proxy.config or will the one below do for this

      <serverUrl url="http://www.arcgis.com" 
          username="AAA"
          password="XXX"            
       rateLimit="600"
       rateLimitPeriod="60"
       matchAll="true">
      </serverUrl>


Either way I am going to wait until my network proxy issue are sorted so I can bypass it all together to eliminate any issues here.

Thanks again for all your help as it has been invaluable,
D
0 Kudos
DanielMclaglen
Emerging Contributor
Ok finally made some progress as can now bypass my network proxy.

If I set my proxy config to https://www.arcgis.com

Then I get the following error which I am guessing means the proxy is not generating the token as it can't match the request to the proxy config?

{"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}}

If I set my proxy config to http://www.arcgis.com then I get the error that the request is not made over SSL.

Everything is set to ssl apart from localhost.

    <link rel="stylesheet" href="https://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="https://js.arcgis.com/3.9/js/esri/css/esri.css">
    <script src="https://js.arcgis.com/3.9/"></script>


D
0 Kudos
DanielMclaglen
Emerging Contributor
Man alive that drove me mad but I have finally got it sorted.

The issues.
1. My network proxy so I bypass this altogether as even authenticating with it causes problems (or at least caused me problems).
2. The fact some requests are generated as http and some as https (not sure why that is).

So my proxy config looks like this

    <serverUrl url="https://services2.arcgis.com/gGQziFjRK38YOiW5/arcgis/rest/services"              
      username="UserName"
      password="Password"
      rateLimit="600"
      rateLimitPeriod="60"
      matchAll="true">
    </serverUrl>        
                 
    <serverUrl url="https://www.arcgis.com" 
      username="UserName"
      password="Password"
     rateLimit="600"
     rateLimitPeriod="60"
     matchAll="true">
    </serverUrl>

    <serverUrl url="http://www.arcgis.com"
      username="UserName"
      password="Password"
      rateLimit="600"
      rateLimitPeriod="60"
      matchAll="true">
    </serverUrl>


However I can still reference the 3.9 api using either http or https.

D
JohnGravois
Deactivated User
glad to hear it Daniel.  thanks for taking the time to recap.
0 Kudos