Greetings,
I am attempting to add features from a Flex application using the REST API addFeature call. I pieced together a function from various sources But it doesn't seem to do much:
This function runs and does not produce an error. However, it also does not add my easement feature.Has anyone tried adding JSON Features to a featureService using both the Flex and REST APIs? Any tips, tricks, points or general information will be greatly appreciated.
Thanks, Tyler
You have to POST the URLRequest and assign the variables using URLVariables. What I really needed to do is something like this:
private function addGraphicToEasementLayer(graphic:Graphic):void
{
var easementJSON:Object = graphic.toJSON();
var easmentString:String = "["+JSONUtil.encode(easementJSON)+"]";
trace("the Easement is " + easmentString);
var request:URLRequest = new URLRequest('http://yourdomain/ArcGIS/rest/services/SharedMaps/GreenwayEasementsTest/FeatureServer/0/addFeatures');
var urlVars:URLVariables = new URLVariables();
urlVars.f = "json";
urlVars.features = easmentString;
urlVars.gdbVersion = "";
urlVars.rollbackOnFailure = true;
request.data = urlVars;
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.load(request);
}
Works like a charm!
Hope this helps someone else.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.