AnsweredAssumed Answered

Cannot see the Points on the map in ArcGIS Online, data imported via REST

Question asked by ionut.plesca.geopal on Jun 8, 2017
Latest reply on Jun 23, 2017 by ionut.plesca.geopal

Hi people,

I'm having some troubles seeing the Points on a Layer under a Feature Service - for some reason, although all the steps below go without error, I'm not able to see anything on the map, though the data is there. Probably I'm doing something wrong with the syntax needed for the ArcGIS REST API. Can anyone go over them and give me a helping hand? Much appreciated!

 

What I'm trying to achieve is: push data to a layer and view it within a map in ArcGIS Online. My steps, using REST calls are like these:

1. Create a hosted feature service

(note: [username], [token] and [identifier] are replaced with proper values)

URL:

POST https://www.arcgis.com/sharing/rest/content/users/[username]/createService

PHP DATA:

array (
  'token'      => '[token]',
  'f'          => 'json',
  'outputType' => 'featureService',
  // json encoded below
  'createParameters' => '{
        "name":"Good test",
        "serviceDescription":"GeoPal assets",
        "description":"Assets imported through GeoPal assets",
        "hasStaticData":false,
        "supportedQueryFormats":"JSON",
        "capabilities":"Create,Delete,Query,Update,Editing",
        "units":"esriMeters",
        "spatialReference":{
            "wkt":"WGS_1984_Web_Mercator"
        },
        "initialExtend":{
            "type":"extent",
            "xmin":-8591193.02146,
            "ymin":4686637.93832,
            "xmax":-8560023.56404,
            "ymax":4726686.26299,
            "spatialReference":{
                "wkt":"WGS_1984_Web_Mercator"
            }
        },
        "xssPreventionInfo":{
            "xssPreventionEnabled":true,
            "xssPreventionRule":"InputOnly",
            "xssInputRule":"rejectInvalid"
        }
    }',
)

2. Create a layer under the above Feature Service

URL:

POST https://services6.arcgis.com/[identifier]/arcgis/rest/admin/services/Good%20test/FeatureServer/addToDefinition

PHP DATA

array (
  'token' => '[token]',
  'f'     => 'json',
  // json encoded
  'addToDefinition' => '{
      "layers":[{
          "units":"esriDecimalDegrees",
          "name":"GeoPal assets layer",
          "type":"Feature Layer",
          "displayField":"NAME",
          "description":"Imported GeoPal assets",
          "copyrightText":"",
          "defaultVisibility":true,
          "relationships":[],
          isDataVersioned":false,
          "supportsRollbackOnFailureParameter":true,
          "supportsAdvancedQueries":true,
          "geometryType":"esriGeometryPoint",
          "minScale":0,
          "maxScale":0,
          "extent":{
              "type":"extent",
              "xmin":-8591193.02146,
              "ymin":4686637.93832,
              "xmax":-8560023.56404,
              "ymax":4726686.26299,
              "spatialReference":{
                  "wkt":"WGS_1984_Web_Mercator"
              }
          },
          "drawingInfo":{
              "transparency":0,
              "labelingInfo":null,
              "renderer":{
                  "type":"simple",
                  "symbol":{
                      "color":[76,129,205,255],
                      "size":5,
                      "angle":0,
                      "xoffset":0,
                      "yoffset":0,
                      "type":"esriSMS",
                      "style":"esriSMSSquare",
                      "outline":{
                          "color":[80,80,80,255],
                          "width":3,
                          "type":"esriSMS",
                          "style":"esriSMSCircle"
                      }
                  }
              }
          },
          "allowGeometryUpdates":true,
          "hasAttachments":true,
          "htmlPopupType":"esriServerHTMLPopupTypeNone",
          "hasM":false,
          "hasZ":false,
          "objectIdField":"OBJECTID",
          "globalIdField":"OBJECTID",
          "fields":[{
              "name":"OBJECTID",
              "alias":"Object ID",
              "type":"esriFieldTypeOID",
              "nullable":false,
              "editable":false,
              "domain":null,
              "defaultValue":null
          }, {
              "name":"NAME",
              "alias":"Asset name",
              "nullable":false,
              "editable":true,
              "domain":null,
              "defaultValue":null,
              "type":"esriFieldTypeString"
          }],
          "indexes":[],
          "types":[],
          "templates":[],
          "supportedQueryFormats":"JSON,geoJSON",
          "hasStaticData":true,
          "maxRecordCount":1000,
          "capabilities":"View,Query,Editing,Create,Update,Delete"
      }]
  }',
)

 

3. Push data to the layer

URL

POST https://services6.arcgis.com/[identifier]/arcgis/rest/services/Good%20test/FeatureServer/0/addFeatures

PHP DATA

array (
    'token' => '[token]',
    'f'     => 'json',
    // json encoded
    'features' => '[{
        "geometry":{
            "x":"53.32712320000000",
            "y":"-6.38504700000000"
        },
        "attributes":{
            "OBJECTID":" TMP:6011T2EWFQ",
            "NAME":"Asset # TMP:6011T2EWFQ"
        }
    }, {
        "geometry":{
            "x":"-6.16427469253540",
            "y":"39.19896697998047"
        },
        "attributes":{
            "OBJECTID":" TMP:6SFDKNX48O",
            "NAME":"Asset # TMP:6SFDKNX48O"
        }
    }, {
        "geometry":{
            "x":"34.02233442402884",
            "y":"-118.28009672462940"
        },
        "attributes":{
            "OBJECTID":" TMP:9M911WXZEO",
            "NAME":"set from script"
        }
    }]',
)

Outcomes