|
POST
|
Would seem you need to tell the HttpClient to use DefaultCredentials using HttpClient httpClient = new HttpClient(new HttpClientHandler{UseDefaultCredentials = true});
... View more
12-28-2020
11:00 AM
|
0
|
0
|
4948
|
|
POST
|
I am having an issue outlined here: https://community.esri.com/t5/arcgis-rest-api-questions/getting-token-generatetorken-in-c-from-windows-authenticated/td-p/1012188 This is really associated to using rest from C#, but thought maybe someone here has had a similar experience. Plus I figure the Runtime API has to be doing something similar and things work from Runtime Thoughts?
... View more
12-28-2020
08:50 AM
|
0
|
1
|
1426
|
|
POST
|
I am trying to use the generateToken endpoint with a installation that uses Windows Authentication. In Runtime or in Python API in this case you would send the username and password as empty strings. However, doing so in a standalone C# program calling into the generateToken endpoint returns an error 401 unauthorized access. I have tried to do this a couple ways one of which follows HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, "https://PORTALSERVER/portal/sharing/rest/generateToken") { Content = TokenRequestContent() };
using HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Referrer = new Uri("https://PORTALSERVER/portal");
var t = await httpClient.SendAsync(msg);
var s = await t.Content.ReadAsStringAsync();
private FormUrlEncodedContent TokenRequestContent()
{
var parameters = new Dictionary<string, string>
{
{"username", ""},
{"password", ""},
{"client", "requestip" },
{"expiration", "1440" },
{"f", "pjson" },
};
var content = new FormUrlEncodedContent(parameters);
return content;
} Which fails <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title> If I use the web browser to just make the call and send empty username and password I get the token as expected. If I change and use the same code but to request from AGOL is works: HttpRequestMessage msg = new HttpRequestMessage(HttpMethod.Post, "https://arcgis.com/sharing/rest/generateToken") { Content = TokenRequestContent() };
using HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Referrer = new Uri("https://arcgis.com");
var t = await httpClient.SendAsync(msg);
var s = await t.Content.ReadAsStringAsync();
private FormUrlEncodedContent TokenRequestContent()
{
var parameters = new Dictionary<string, string>
{
{"username", "AGOLUSER"},
{"password", "AGOLPASSWORD"},
{"client", "requestip" },
{"expiration", "1440" },
{"f", "pjson" },
};
var content = new FormUrlEncodedContent(parameters);
return content;
} I will get a valid token returned in json as expected. I have compared the Fiddler message for the request sent to the local portal both from my code and what is sent from the request done from the Web UI and both seem the same. Why would sending the same request with HttpClient not behave like the request if sent from a browser?
... View more
12-23-2020
01:45 PM
|
1
|
2
|
5115
|
|
POST
|
The MapView has a LocationDisplay property. LocatonDisplay has AutoPanMode. mapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Recenter;
... View more
12-21-2020
10:17 AM
|
0
|
11
|
5547
|
|
POST
|
In a portal implementation we have considerably larger offline data, so I do not know if there is a size limit. The size of the data being processed would be associated to the number of changes, though, not the size of the actual offline replica. When a Sync occurs what happens on upload is: Runtime processes the database to generate a temporary delta database Uploads the delta file to server using rest call (returns an identifier of file) Make call to sync giving a location of the uploaded file via Rest What you can do when the job fails to call job.ToJson() and log this. This is a lot of the communication between server and client during the sync and may give more information. As the message may not mean a whole lot
... View more
12-17-2020
12:46 PM
|
1
|
2
|
3857
|
|
POST
|
Not sure I understand this comment: // Using following code to load map on iPad. The tpk file is stored in Files app on iPad and we are allowing user to select the tpk file Pretty sure in order to load the file it will need to be in you project folder for the application. To create a project folder the following permission is set in info.plist <key>UIFileSharingEnabled</key>
<true/> That will create a project folder that can be found looking at the On My iPad tab in the file browser There will be the project folder and the tpk file can be located there. Below are folders for two applications installed on my iPad. If you have collector you would see a folder for Collector
... View more
12-15-2020
11:10 AM
|
0
|
0
|
1691
|
|
POST
|
In general terms by passing the view model into the ICommand implementation (RadarCommand), the ICommand implementation and the view model are now tightly coupled. This defeats one of the driving principles of MVVM. You would need an ICommand implementation for every bound command.
... View more
12-04-2020
08:48 AM
|
0
|
0
|
5465
|
|
POST
|
I am taking a map offline. When I do the parameters passed are 0,0 to not set a min/max scale var parameters = await offlineMapTask.CreateDefaultGenerateOfflineMapParametersAsync(geometry!, 0, 0); However, for a certain WebMap it does set a MaxScale (to 1128 if that matters) . I just have no idea what within the WebMap would cause this to be set. In a browser I can zoom in on the WebMap, but not offline. Anyone know where to look to find what might be setup incorrectly on the WebMap? Thanks
... View more
12-03-2020
09:25 AM
|
0
|
0
|
743
|
|
POST
|
I tend to always wonder why someone doesn't want to use an external MVVM library, but that is a conversation for another day. Without an external library generally, one would want to roll their own delegate command ICommand implementation which is pretty straight forward public class DelegateCommand : ICommand
{
private readonly Predicate<object> _canExecute;
private readonly Action<object> _execute;
public DelegateCommand(Action<object> execute) : this(execute, null)
{
}
public DelegateCommand(Action<object> execute, Predicate<object> canExecute)
{
_execute = execute;
_canExecute = canExecute;
}
#region ICommand Members
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return _canExecute == null || _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
#endregion
public void RaiseCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
} With this one can just create an ICommand and pass the action into this DelegateCommand. To simplify the MainWindow Xaml, instead of making the view model a static resource, bind it as the DataContext. By doing this one does not need to set the source of the binding, it will be the defined DatContext <Window x:Class="WpfApp2.MainWindow"
...
xmlns:local="clr-namespace:WpfApp2"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" >
<Window.DataContext>
<local:MapViewModel />
</Window.DataContext>
<Grid>
<esri:MapView Map="{Binding Map}" x:Name="mapView" />
<!-- Command is bound to ICommand on ViewModel -->
<Button Content="Add Layer" Command="{Binding AddLayerCommand}"
Height="40" Width="80" Margin="10,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid>
</Window> Now we just wire up our ViewModel public class MapViewModel : INotifyPropertyChanged
{
public MapViewModel()
{
CreateNewMap();
}
private void CreateNewMap()
{
//For sample using the viewpoint of the layer in code,
// personally I would not set an initial extent from a feature layer that needed to load at startup,
// but that's also a conversation for another day
var targetGeometry =
Geometry.FromJson(
"{\"xmin\":-13240129.679701095,\"ymin\":3994281.9887753138,\"xmax\":-13106722.92583799,\"ymax\":4101417.5063218847,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}}");
Map = new Map(Basemap.CreateImageryWithLabels())
{
InitialViewpoint = new Viewpoint(targetGeometry!)
};
Map.Loaded += (sender, args) => { Console.WriteLine("all done loading"); };
}
private Map _map;
public Map Map
{
get => _map;
set
{
_map = value;
OnPropertyChanged(nameof(Map));
}
}
//So here just create a DelegateCommand passing in the delegate, it will execute when invoked
public ICommand AddLayerCommand => new DelegateCommand(ExecuteAddLayer);
//As pointed out by Morten, generally an async should return a Task,
// In this situation void is proper because it is a Delegate command
private async void ExecuteAddLayer(object obj)
{
try
{
var trailHeadsLayer = new FeatureLayer(new Uri("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0"));
await trailHeadsLayer.LoadAsync();
Map.OperationalLayers.Add(trailHeadsLayer);
await Map.LoadAsync();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
//remove INotifyPropertyChanged for sample purposes
}
... View more
12-03-2020
09:15 AM
|
1
|
2
|
5491
|
|
POST
|
You're pretty much there. Layers are added to a Map, not to a MapView. You already have the Map which is bound to your MapView's Map property public async void AddAnotherLayer()
{
//Do something to create a feature layer
FeatureLayer featureLayer = new FeatureLayer(featureServiceUri);
await featureLayer.LoadAsync();
Map.OperationalLayers.Add(featureLayer);
}
... View more
12-02-2020
12:56 PM
|
0
|
2
|
5514
|
|
POST
|
I would guess that is maybe not the best description of the return, I don't know what condition could actually cause a false to return. I think you describe it correctly, Start basically kicks off a separate thread that then starts the post operation and performs the status checks (firing a ProgessChanged each time). So the first ProgressChanged really comes from the initial statusUrl returned in the primary Post request. This way from the Runtime application you have a true synchronous method to kick it off without waiting on anything (even the initial post response). What are you wanting the JobId for? Or do you just want a little better feedback in the calling method to confirm the job truly started. I do see how providing a method described makes sense
... View more
12-01-2020
07:17 AM
|
0
|
1
|
1921
|
|
POST
|
I added this to occur in my processing which seems to resolve the issue, not really excited about it as a workaround, but for now will have to do private bool _firstSync = true;
private async Task InitialzeTokens()
{
if ( !_firstSync ) return;
foreach (var featureLayer in _map.OperationalLayers.OfType<FeatureLayer>())
{
var pars = new QueryParameters {WhereClause = "1=0", MaxFeatures = 1};
if ( !(featureLayer.FeatureTable is GeodatabaseFeatureTable gdbFeatureTable) ) continue;
if ( gdbFeatureTable.Geodatabase?.Source == null ) continue;
var serviceFeatureTable = new ServiceFeatureTable(gdbFeatureTable.Geodatabase.Source);
try
{
await serviceFeatureTable.LoadAsync();
var _ = await serviceFeatureTable.QueryFeaturesAsync(pars);
}
catch (Exception)
{
//_log.Error(e, e.Message);
}
}
_firstSync = false;
}
... View more
11-30-2020
01:29 PM
|
0
|
0
|
4336
|
|
POST
|
So I tried this with the change that I first log onto AGOL prior to the sync, in that case I see similar results except it never actually goes into the ChallengeHandler. I was thinking maybe it has to do with the WebMap, but I tried with another WebMap and seems to still have the issue. I am having a hard time with no one being able to duplicate with this happening every single time I try a first sync. I am willing to share the code, privately, if someone is willing to do that.
... View more
11-30-2020
11:29 AM
|
0
|
0
|
4340
|
|
POST
|
Hi, I tried attaching a file to a post. This was just a basic text file. I tried to upload using different extensions and even copying the contents into a text editor and re-saving in case something was wrong with the file. All attempts failed, I got the following message of similar
... View more
11-30-2020
10:31 AM
|
0
|
2
|
1193
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-11-2026 09:07 AM | |
| 1 | 10-23-2025 12:16 PM | |
| 1 | 10-19-2022 01:08 PM | |
| 1 | 09-03-2025 09:25 AM | |
| 1 | 04-16-2025 12:37 PM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|