Use ArcGIS Server REST resources without an official SDK. This is a netstandard 2.1 library, it was ported from ArcGIS.PCL. It is not endorsed, affiliated or supported by Esri. Use v1.x of this library if you need to use the netstandard 2.0 version.
A typical use case would be the need to call some ArcGIS REST resource from server .NET code or maybe a console app. The features that this returns can be used directly as Esri JSON in JavaScript apps using the Esri JS API.
Works with secure and non-secure ArcGIS Server on premise / in the cloud, Portal for ArcGIS and ArcGIS Online. Also supports converting GeoJSON
If you are calling a REST operation you will need to create a gateway to manage the request. There are a few different ones but the most basic is called PortalGateway
and this can be used for connecting directly to services with ArcGIS Server.
Create an instance of that by specifying the root url of your server. The format of the root url is scheme://host:port/instance so a typical default ArcGIS Server for your local machine would be http://localhost:6080/arcgis, note that you do not need to include rest/services
in either the root url or your relative urls as it gets added automatically. One thing to look out for is that the url is case sensitive so make sure you enter it correctly.
var gateway = new PortalGateway("https://sampleserver3.arcgisonline.com/ArcGIS/");
// If you want to access secure resources then pass in a username / password
// this assumes the token service is in the default location for the ArcGIS Server
var secureGateway = new PortalGateway("https://sampleserver3.arcgisonline.com/ArcGIS/", "username", "password");
// Or use the static Create method which will discover the token service Url from the server Info endpoint
var autoTokenProviderLocationGateway = await PortalGateway.Create("https://sampleserver3.arcgisonline.com/ArcGIS/", "username", "password");
Now you have access to the various operations supported by it. For example to call a query against a service
var query = new Query("Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint())
{
Where = "magnitude > 4.0"
};
var result = await gateway.Query<Point>(query);
Supports the following as typed operations:
CheckGenerateToken
create a token automatically via anITokenProvider
Query
query a layer by attribute and / or spatial filters, also possible to doBatchQuery
QueryForCount
only return the number of results for the query operationQueryForIds
only return the ObjectIds for the results of the query operationQueryForExtent
return the bounding extent for the result of the query operationQueryAttachments
return attachments grouped by the source feature object Ids and global idQueryDomains
returns full domain information for the domains referenced by the layers in the serviceFind
search across n layers and fields in a serviceApplyEdits
post adds, updates and deletes to a feature service layerDeleteFeatures
delete features in a feature layer or tableGeocode
single line of input to perform a geocode using a custom locator or the Esri world locatorCustomGeocode
single line of input to perform a geocode using a custom locatorSuggest
lightweight geocode operation that only returns text results, commonly used for predictive searchingReverseGeocode
find location candidates for a input point locationSimplify
alter geometries to be topologically consistentProject
convert geometries to a different spatial referenceBuffer
buffers geometries by the distance requestedDescribeSite
returns a url for every service discoveredCreateReplica
create a replica for a layerUnregisterReplica
unregister a replica based on the IdDeleteAttachments
delete attachments that are associated with a featurePing
verify that the server can be accessedInfo
return the server information such as version and token authentication settingsDescribeLegends
return legend information of layersDescribeServices
return services information (name, sublayers etc.)DescribeService
return service information (name, sublayers etc.)DescribeLayer
return layer informationHealthCheck
verify that the server is accepting requestsGetFeature
return a feature from a map/feature serviceExportMap
get an image (or url to the image) of a service
REST admin operations:
PublicKey
- admin operation to get public key used for encryption of token requestsServiceStatus
- admin operation to get the configured and actual status of a serviceServiceReport
- admin operation to get the service reportStartService
- admin operation to start a serviceStopService
- admin operation to stop a serviceServiceStatistics
- admin operation to get the statistics of a service
There are also methods to add / update and download attachments for a feature and you can extend this library by writing your own operations.
Refer to the integration test project for more examples.
Absolutely! Please feel free to raise issues, fork the source code, send pull requests, etc.
No pull request is too small. Even whitespace fixes are appreciated. Before you contribute anything make sure you read CONTRIBUTING.
Install-Package Anywhere.ArcGIS
dotnet add package Anywhere.ArcGIS
paket add Anywhere.ArcGIS
You can also get the code from this site.
Anywhere.ArcGIS uses Semantic Versioning.
Icon made by Freepik from www.flaticon.com