Convert Map service layers to kml format

Discussion created by djain-esristaff on Mar 24, 2014

I am using javascript api 3.8 and working on dynamic map service. I need to export the selected features to kml format.
I tried using the REST API link


to convert data to kml and it does convert the data, but actually it does provide the link to retreive the data from arcgis server and pull it on Google Earth.
I want to convert the data in kml in such a way that it itself carries the data, becuase this kml will get distributed to users who do not hav access to arcgis server and are working on remote locations.