AnsweredAssumed Answered

Create Replica from FeatureService with Basic authentication on Windows Phone, Return error 404

Question asked by tstorck on Sep 23, 2016
Latest reply on Sep 26, 2016 by tstorck

Hi,

 

I've tried to create a replica from a FeatureService that has basic authentication. When I request the replica from Windows Store, it works fine. When the request comes from Windows Phone, the callback returns a 404 Error (URL not found).

 

PS.: It's an UWP project and I'm using the code below for the both applications.

 

DTO.AGSAuth agsAuth = await restConn.ArcGISServerRequestCredentialAsync(this.featureService.Url);

GeodatabaseSyncTask gdbTask = new GeodatabaseSyncTask(new Uri(this.featureService.Url));

if (agsAuth != null)
{
    switch (agsAuth.mode)
    {
        case "TOKEN":
            DTO.AGSAuthToken agsToken = agsAuth as DTO.AGSAuthToken;
            gdbTask.Token = agsToken.credential.token;
            break;
        case "BASIC":
            agsAuthBasic = agsAuth as DTO.AGSAuthBasic;

            byte[] data = Convert.FromBase64String(agsAuthBasic.credential.key);
            string[] credentials = Encoding.UTF8.GetString(data, 0, data.Length).Split(':');

            string userName = credentials[0].Split('\\')[1], passWord = credentials[1], domain = credentials[0].Split('\\')[0];

            System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(userName, passWord, domain);

            var credential = new ArcGISNetworkCredential
            {
                Credentials = networkCredential,
                ServiceUri = this.featureService.Url
            };

            IdentityManager.Current.AddCredential(credential);
            break;
        default:
            break;
    }
}

featureService.Layers = await new DAO.DAOFeatureServiceLayer().GetFromServiceAsync(featureService);
featureService.Extent = new DAO.DAOMapa().GetExtent(App.Usuario);

var gdbParams = new GenerateGeodatabaseParameters(featureService.Layers.Select(x => x.ID), featureService.Extent)
{
    OutSpatialReference = new SpatialReference(102100),
    SyncModel = SyncModel.PerLayer,
    ReturnAttachments = true
};

await gdbTask.GenerateGeodatabaseAsync
    (
        gdbParams,
        GdbCreatedCompleteCallback,
                            new TimeSpan(0, 1, 0),
                            null,
                            CancellationToken.None
                            );

Outcomes