Trying to make a new feature on a map. I got the code like this where i`m using atm hardcoded coordinates:

function addFeature(browserEvent, dataSource) {
  //add feature
  var url = dataSource + '/0/addFeatures';
  var coordinate = browserEvent.coordinate;
  var x = coordinate[0];
  var y = coordinate[1];
  //console.log('De locatie is ' + coordinate);

  var jsonTemp = [{
    'geometry': {
      'x': 248460.375,
      'y': 440990.21880000085
    'attributes': {
      'relcp86d_': 0,
      'relcp86d_i': 99999,
      'symbol': 77,
      'polygonid': 1,
      'scale': 1,
      'angle': 10,
      'omschrijvi': 'Testobject'

  var jsonTempStringified = JSON.stringify(jsonTemp);
  var jsonTempStringifiedParsed = JSON.parse(jsonTempStringified);

    url: url,
    dataType: 'json',
    type: 'POST',
    data: jsonTempStringifiedParsed,
    success: function(data) {
    error: function(xhr, ajaxOptions, thrownError) {


I tried to use this exact json in the browser and it works(Link) but using it via this it's giving me errors and i tried all kind of things. As you can see from a previous post i really have problems with json and the arcgis server services.

Error code is:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I also tried to remove the [] doesn't help it keeps having the same problem. As you can see i have also tried with or without or even double parse/stringify just nothing helps.


I got the answer, i found out my data was incorrect. The data should be like this

data: 'f=json&features=' + jsonTempStringified,

For me this worked.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.