Secure Service get layer information with external application

3507
1
Jump to solution
11-13-2015 11:44 AM
JimBridge
Occasional Contributor

I have .net app that retrieves avialable layers and fields to populate a report.  This application currently doesn't have any esri api's involved in it.

I have been getting this information using the following C# code in

mapserver r=  "https://xxx.xxxxxxx.com/arcgis/rest/services/DemoMap/MapServer"

string url = mapserver + (mapserver.Substring(mapserver.Length) == "/" ? "" : "/") + "layers?f=json";

var request = WebRequest.Create(url);

"application/json; charset=utf-8";

string text; var response = (HttpWebResponse)request.GetResponse();

using (var sr = new StreamReader(response.GetResponseStream()))

{ text = sr.ReadToEnd(); }

JavaScriptSerializer jserialize = new JavaScriptSerializer();

layers mylayers = jserialize.Deserialize<layers>(text);

return mylayers;

I now have a map they wish to secure. I'm not sure how I can still retrive the information.

It intially says token missing I manually generated one and concatinated it on to the url. With that I'm getting the login page asking for userid and password.

Any help would be apprececiated.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JimBridge
Occasional Contributor

The token worked fine. I had two issue the token was being generated off a different machine than I was accessing and the url was being generated incorrectly.

Once I corrected those issues everything was fine.

/DemoMapSecure/MapServer/layers?f=json&token=thFg7E-bxSV3rQLch0npGE5wl-kaJpGq1l4Rj0VDj12KAeG615HCneyx65QE2Flb

View solution in original post

0 Kudos
1 Reply
JimBridge
Occasional Contributor

The token worked fine. I had two issue the token was being generated off a different machine than I was accessing and the url was being generated incorrectly.

Once I corrected those issues everything was fine.

/DemoMapSecure/MapServer/layers?f=json&token=thFg7E-bxSV3rQLch0npGE5wl-kaJpGq1l4Rj0VDj12KAeG615HCneyx65QE2Flb

0 Kudos