Add multiple features in addfeatures API request?

2429
2
Jump to solution
01-15-2020 03:44 PM
JackSilburn
New Contributor III

Hi

I'm writing a program to automatically add new data readings to a hosted ArcGIS Online feature layer. See the request URL below:

https://services6.arcgis.com/<ID>/arcgis/rest/services/<my_table>/FeatureServer/0/addFeatures 

The addFeatures request takes a payload item "features", which I can successfully send as:

[
{
"attributes" : {
"Name" : "TestName",
"ColumnTwo": 2
}
}
]

The issue: not being able to send multiple 'features' in the above section. My hunch is I am simply miss-typing the json data.

Thank you.

1 Solution

Accepted Solutions
RandyBurton
MVP Alum

Features use a format like (assuming you are not including geometry):

[
  {
    "attributes" : {
      "Name" : "TestName",
      "ColumnTwo": 2
    }
  },
  {
    "attributes" : {
      "Name" : "TestName2",
      "ColumnTwo": 3
    }
  }
]‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Note the coma on line 7 as it joins the next feature.  Typically, the feature would include "attributes" and "geometry".

[
  {
    "attributes" : {
      "Name" : "TestName",
      "ColumnTwo": 2
    },
    "geometry" : {
      "x" : -111.111, 
      "y" : 111.111
    }
  }
]‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

For more information see: Add Features

View solution in original post

2 Replies
RandyBurton
MVP Alum

Features use a format like (assuming you are not including geometry):

[
  {
    "attributes" : {
      "Name" : "TestName",
      "ColumnTwo": 2
    }
  },
  {
    "attributes" : {
      "Name" : "TestName2",
      "ColumnTwo": 3
    }
  }
]‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Note the coma on line 7 as it joins the next feature.  Typically, the feature would include "attributes" and "geometry".

[
  {
    "attributes" : {
      "Name" : "TestName",
      "ColumnTwo": 2
    },
    "geometry" : {
      "x" : -111.111, 
      "y" : 111.111
    }
  }
]‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

For more information see: Add Features

JackSilburn
New Contributor III

I knew I was missing a comma in there somewhere. Thanks mate! 

0 Kudos