Getting a legend on one Mapservice layer

Discussion created by jonesra on Dec 1, 2011
Latest reply on Dec 1, 2011 by njarecha-esristaff
If we use a Mapservice with multiple layers:
Water Mains(3)
  and load just 1 layer (Addresses, index 2), as http://server/ArcGIS/rest/services/General/MapServer/2,

the Legend sample code gives this error:

2011-12-01 09:42:46.841 CityView[12055:207] Error encountered while fetching legend : Error Domain=NSCocoaErrorDomain Code=400 "Unable to complete  operation." UserInfo=0x8170d30 {NSLocalizedFailureReason=Invalid URL, NSURL=http://server/ArcGIS/rest/services/General/MapServer/2/Legend?f=json, NSLocalizedDescription=Unable to complete  operation.}

If, on the other hand, we use individual Mapservices for each layer, it works.

Navigating to the arcgis/rest/services/General/Mapservices folder, we see a Legend link, which generates the entire legend for all layers.
There is no legend link for any of the individual layers.