My problem is that I want to get JSON data from ArcGIS for Server

For example: http://xxxx.com/arcgis/rest/services/Map/MapServer/legend?f=pjson

I can get and read JSON data from this URL but if ArcGIS for Server has a password I couldn't so , must use UserCredentials but every sample example use UserCredentials for identity task or querytask but I read data from URL.

how can I post UserCredentials with my AsyncTask ?

  • What are you trying to do? Android developers have to use symbology definitions to build a legend as you cannot use the endpoint you have referenced. If you are trying to parse json outside of the Android API you have to follow the REST API security model, which means you need a token to make the request through a URL in an AsyncTask. You can authenticate with an Android FeatureLayer, get the token out for your user credential and append to your legend request. Is that what you are trying to do? I can share sample code on how to create a Legend if that is what you are trying to do. – jdONeill Aug 22 '14 at 16:23

We don't support those endpoints in the API so you have to honor the REST API and parse the JSON. Secured service endpoints will require you to authenticate on the URL request not with UserCredentials. URL will be in the form of:


You can find an example of creating a Legend in the Android API here.

Disclosure: I am a lead Product Engineer for the ArcGIS Runtime SDK for Android at Esri.

Your Answer

