AnsweredAssumed Answered

How to access a Feature service hosted on arcgis.com which is shared only with particular groups or organization

Question asked by wqadir on Oct 17, 2014
Latest reply on Jan 22, 2016 by lbross

Hi,

 

In my C# application, I am trying to access a Feature service which is hosted on arcgis.com. The feature service is shared only with a group or organization and is NOT public. How can I access this service in my client code. Here is my client code which throws an exception saying the Authentication Token required. I do have the token but dont how to use that token to be successfully able to use the service. This same code runs fine for services that are shared as PUBLIC.

 

               IPropertySet sipPS = new PropertySet();
        sipPS.SetProperty("DATABASE", layerUrl);
        IWorkspaceFactory sipWSF = (IWorkspaceFactory)new ESRI.ArcGIS.Carto.FeatureServiceWorkspaceFactory();
        IWorkspace sipWS = sipWSF.Open(sipPS, 0);
        IFeatureWorkspace sipFWS = (IFeatureWorkspace)sipWS;
        IGroupLayer grpLayer = new GroupLayerClass();
        grpLayer.Name = Constants.ArcGISOnlineGroupLayerName;
        IFeatureClass sipFC = sipFWS.OpenFeatureClass("0");
        IFeatureLayer fl = new FeatureLayerClass();
        fl.Name = featureLayerName;
        fl.FeatureClass = sipFC;
        grpLayer.Add(fl as ILayer);

Outcomes