when I execute "await ExportTileCacheTask.CreateAsync(basemap.Source);" catch a Invalid response: Service does not support tile export. I use map in https://www.arcgis.com/home/group.html?owner=esri&title=Tiled%20Basemaps&start=11&q for export also catch this exception
Hi,
Can you give the exact code / url that you are using? Following seems to work without any problems.
var task = await ExportTileCacheTask.CreateAsync(
new Uri("https://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Street_Map/MapServer"));
Remember that you shouldn't use the service "For export" services as your basemaps, they are intended to be used for taking tiles offline and not visualization.
Hi, Antti
I just tested your uri, it will catch the "Token Required" exception
That is expected if you haven't signed in to ArcGIS Online since the export tiles feature is available to subscribed users (operation doesn't consume credits but you have to be signed in to have a access to it).
You can see more about authentication from Use the Authentication Manager—ArcGIS Runtime SDK for .NET | ArcGIS for Developers or have a look to the samples arcgis-runtime-samples-dotnet/src/WPF/ArcGISRuntime.WPF.Samples/Samples/Security at master · Esri/ar...
Thanks, Antti.
Hi, Antti
I test and I logn the https://github.com/Esri/arcgis-runtime-samples-dotnet/tree/master/src/WPF/ArcGISRuntime.WPF.Samples/...https://github.com/Esri/arcgis-runtime-samples-dotnet/tree/master/src/WPF/ArcGISRuntime.WPF.Samples/..., the second layer USA-Secure display "denied", and I change the first layer uri as https://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Street_Map/MapServer and login also display "denied".
Can you sign into the ArcGIS Online with your credentials? If you sign in to https://www.arcgis.com/home/signin.html does the authentication go through without any problems?
Yes, Antti, I can sign in without problems
Can you try if this works? Just change it to use your credentials.
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(CreateKnownCredentials);
Initialize();
}
private async void Initialize()
{
try
{
var task = await ExportTileCacheTask.CreateAsync(new Uri("https://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Street_Map/MapServer"));
}
catch (Exception ex)
{
// Something unexpected happened, handle properly
MessageBox.Show(ex.Message);
}
}
private string _username = "abcd";
private string _password = "1234";
private async Task<Credential> CreateKnownCredentials(CredentialRequestInfo info)
{
// If this isn't the expected resource, the credential will stay null
Credential knownCredential = null;
try
{
// Create a credential for this resource
knownCredential = await AuthenticationManager.Current.GenerateCredentialAsync
(info.ServiceUri,
_username,
_password,
info.GenerateTokenOptions);
}
catch (Exception ex)
{
// Report error accessing a secured resource
MessageBox.Show("Access to " + info.ServiceUri.AbsoluteUri + " denied. " + ex.Message, "Credential Error");
}
// Return the credential
return knownCredential;
}
}