I was having trouble getting it to work with the server you provided, unfortunately. I keep getting a vague 500 error {"error":{"code":500,"message":"Unable to complete operation.","details":[]}} with no details when trying to post the feature to that server, whether through the function below or the actual addFeatures link. As a result, this may not be 100% reproducible, for which I apologize. Regardless, here's the function where I'm running into trouble. I stole the jquery posting from another Geonet thread. If there's anything else I can try to supply for you, please let me know.
Assume that the arguments "author" and "comment" are user-defined strings, and that "latitude" and "longitude" are stored as numerical representations of coordinates, such as 21.107012104600532.
function addComment(latitude, longitude, author, comment) {
var url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0/addFeatures"; //again, I was unable to get this function to work with this server
var feature = {
"geometry" : {"type" : "Point", "x": longitude, "y":latitude },
"attributes" : {
"name" : author,
"comments": comment
},
};
$.post(url, {
features: JSON.stringify([feature]),
f: "json"
})
.done(function(results) {
console.log(results);
})
.fail(function(error) {
console.log(error);
});
}
This function works to post it to the server I'm working with, but when it does, I believe all the coordinates are read in as measurements in meters as opposed to latitude and longitude coordinates because they're all around the origin. I've tried multiplying by different values to get closer to where these points should be, but I feel like that's not the most effective way to solve this problem. I've also tried specifying a spatialReference and wkid for the feature, but that wasn't helpful either.