Wednesday, March 28, 2018

Arcgis REST API Append Data to Feature Layer

I needed to append data to an existing Hosted Feature Layer with multiple layers. I found that I was able to append the data by submitting a JSON request, but the data I was adding never showed up on the map. I found a few suggestions such as doing a refresh via javascript on the layer or turning off synchronization which I did. It turns out is was an issue with the data I was submitting.
I added the data at first using the addFeatures and then I tried the applyEdits...both worked fine. I could see the data in the Data tab online but not in the map.
The request looked like this:
[{
'attributes' : {
'fieldName1' : 'junk data',
'latitude': 89.1000,
'longitude' : -119.333
}
}]
For some reason, I thought that the Lat/Long included in the attributes was how the original data was being mapped, so in reading the instructions, I ignored the Geometry part of the request, which ended up being my problem. I had to submit the request like this:
[{
'geometry' : {'x' : -119.333, 'y' : 89.1000},
'attributes' : {
'fieldName1' : 'junk data',
'latitude': 89.1000,
'longitude' : -119.333
}
}]
Mind your {} and [] and ,,,, and data types and you should be good :)

No comments:

Post a Comment