Add Feature Polygon via REST API

631
3
08-11-2021 01:28 PM
Labels (3)
lougalban
New Contributor

I'm trying to add a feature layer via REST API, but its not working. I only have 4 corners coordinates. Below is my code.

'geometry' => [
                'hasZ'  => false,
                'hasM'  => false,
                'rings' => [[[121.458756,15.807697],[121.458784,15.807773],[121.459115,15.807692],[121.459088,15.807596],[121.458756,15.807697]]],
                'spatialReference' => [
                    "wkid" => 4326
                 ]   
]

 

Any idea?

 

0 Kudos
3 Replies
DavidPike
MVP Frequent Contributor

which api is this? I don't get the syntax => 

Shouldn't rings be closed off with a repeat of the initial vertex?  Do you have a reference to where you've got this from? 

lougalban
New Contributor

Hi thank you for the response, I'm very new to ArcGIS. It was close, first and last is same coordinates.. Did I do it wrong?

This is my reference:
Add Feature API:
https://developers.arcgis.com/rest/services-reference/enterprise/add-features.htm
Geometry Polygon:
https://developers.arcgis.com/documentation/common-data-types/geometry-objects.htm

0 Kudos
AmandaRing
Esri Contributor

You need to create a properly formatted JSON feature object.

It would look something like:

[{
	"geometry": {
		"rings": [
			[
				[121.458756, 15.807697],
				[121.458784, 15.807773],
				[121.459115, 15.807692],
				[121.459088, 15.807596],
				[121.458756, 15.807697]
			]
		],
		"spatialReference": {
			"wkid": 4326
		}
	}
}]

 

Amanda
Product Engineer - Web Analysis
0 Kudos