Hi everyone,
I am trying to write an app that creates a feature service, however I am seeing some strange things (or it might/hopefully just be me). I won't go into each iteration I have tried but I will summarise some of the results and comments.
var jsonFS = appFolder.fileUrl("featureService.json")
console.log(jsonFS)
addPortalItemWithJson(newTracklog, jsonFS)
using a local file file:// (FileFolder.fileUrl from AppFramework) successfully creates the item but when I look at the service in ArcGIS.com I get an error loading the table in the data tab. Could you please be specific to what actually has to go into this file. I copied a previous feature layer JSON content and saved it to a file. I have attached a link at the bottom. Also the service URL is malformed.
addPortalItemWithUrl(newTracklog, https://services.arcgis.com/ZN2A4THMtsVQ15wW/ArcGIS/rest/services/TestLocationTrackingLayer/FeatureS...)
addPortalItemWithUrl(newTracklog, "https://www.dropbox.com/s/b8mvzyo82108irw/featureService.json", jsonFS)
Using a http:// file successfully added the item by using a feature service url but now the service url is pointing to the original feature service. It has effectively made a layer view. Once again what am I supposed to do with this. Also tested with a url outside of the environment and get a successful creation but invalid data.
Lucas Danzinger and FYI https://community.esri.com/migrated-users/152825
https://www.dropbox.com/s/b8mvzyo82108irw/featureService.json?dl=0
Look forward to hearing what I am doing wrong
Solved! Go to Solution.
Creating a Feature Service is done in two steps:
Here is the sample parameters for Create Service:
{
"name": "tracklog_101",
"serviceDescription": "Tracklog 101 (04-Jan-2018 8:30 AM)",
"currentVersion":10.3,
"hasVersionedData":false,
"supportsDisconnectedEditing":false,
"hasStaticData":false,
"maxRecordCount":1000,
"supportedQueryFormats":"JSON",
"capabilities":"Query,Editing,Create,Update,Delete",
"description":"",
"copyrightText":"",
"allowGeometryUpdates":true,
"units":"esriMeters",
"syncEnabled":false,
"editorTrackingInfo":{
"enableEditorTracking":false,
"enableOwnershipAccessControl":false,
"allowOthersToUpdate":true,
"allowOthersToDelete":true
},
"xssPreventionInfo":{
"xssPreventionEnabled":true,
"xssPreventionRule":"InputOnly",
"xssInputRule":"rejectInvalid"
},
"tables":[
],
"_ssl":false
}
Here is a sample parameters for Add To Definition:
{
"layers": [
{
"adminLayerInfo": {
"geometryField": {
"name": "geometry",
"srid": 4326
}
},
"allowGeometryUpdates": true,
"capabilities": "Query,Editing,Create,Update,Delete",
"copyrightText": "",
"defaultVisibility": true,
"description": "",
"displayField": "",
"drawingInfo": {
"labelingInfo": null,
"renderer": {
"description": "Tracklog",
"label": "Tracklog",
"symbol": {
"angle": 0,
"color": [
255,
0,
0,
255
],
"outline": {
"color": [
255,
255,
0,
255
],
"width": 1
},
"size": 8,
"style": "esriSMSCircle",
"type": "esriSMS",
"xoffset": 0,
"yoffset": 0
},
"type": "simple"
},
"transparency": 0
},
"extent": {
"spatialReference": {
"wkid": 4326
},
"type": "extent",
"xmax": 180,
"xmin": -180,
"ymax": 90,
"ymin": -90
},
"fields": [
{
"alias": "ObjectID",
"defaultValue": null,
"domain": null,
"editable": false,
"name": "objectid",
"nullable": false,
"type": "esriFieldTypeOID"
},
{
"alias": "GlobalID",
"defaultValue": null,
"domain": null,
"editable": false,
"length": 38,
"name": "globalid",
"nullable": false,
"sqlType": "sqlTypeGUID",
"type": "esriFieldTypeGlobalID"
},
{
"alias": "Latitude",
"domain": null,
"editable": true,
"name": "latitude",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Longitude",
"domain": null,
"editable": true,
"name": "longitude",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Altitude",
"domain": null,
"editable": true,
"name": "altitude",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Easting",
"domain": null,
"editable": true,
"name": "easting",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Northing",
"domain": null,
"editable": true,
"name": "northing",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "UTC Date & Time",
"domain": null,
"editable": true,
"name": "utcdatetime",
"nullable": true,
"type": "esriFieldTypeDate"
},
{
"alias": "UTC Date",
"domain": null,
"editable": true,
"name": "utcdate",
"nullable": true,
"type": "esriFieldTypeDate"
},
{
"alias": "UTC Time",
"domain": null,
"editable": true,
"length": 20,
"name": "utctime",
"nullable": true,
"type": "esriFieldTypeString"
},
{
"alias": "Sentence",
"domain": null,
"editable": true,
"length": 255,
"name": "sentence",
"nullable": true,
"type": "esriFieldTypeString"
}
],
"geometryType": "esriGeometryPoint",
"globalIdField": "globalid",
"hasAttachments": true,
"hasM": false,
"hasStaticData": false,
"hasZ": false,
"htmlPopupType": "esriServerHTMLPopupTypeAsHTMLText",
"id": 0,
"isDataVersioned": false,
"maxRecordCount": 1000,
"maxScale": 0,
"minScale": 0,
"name": "Tracklog",
"objectIdField": "objectid",
"relationships": [],
"supportedQueryFormats": "JSON",
"supportsAdvancedQueries": true,
"supportsRollbackOnFailureParameter": true,
"supportsStatistics": true,
"templates": [],
"type": "Feature Layer",
"typeIdField": "",
"types": [],
"indexes": [
{
"description": "GlobalID index",
"fields": "globalid",
"isAscending": false,
"isUnique": true,
"name": "GlobalIDIndex"
}
]
}
]
}
Creating a Feature Service is done in two steps:
Here is the sample parameters for Create Service:
{
"name": "tracklog_101",
"serviceDescription": "Tracklog 101 (04-Jan-2018 8:30 AM)",
"currentVersion":10.3,
"hasVersionedData":false,
"supportsDisconnectedEditing":false,
"hasStaticData":false,
"maxRecordCount":1000,
"supportedQueryFormats":"JSON",
"capabilities":"Query,Editing,Create,Update,Delete",
"description":"",
"copyrightText":"",
"allowGeometryUpdates":true,
"units":"esriMeters",
"syncEnabled":false,
"editorTrackingInfo":{
"enableEditorTracking":false,
"enableOwnershipAccessControl":false,
"allowOthersToUpdate":true,
"allowOthersToDelete":true
},
"xssPreventionInfo":{
"xssPreventionEnabled":true,
"xssPreventionRule":"InputOnly",
"xssInputRule":"rejectInvalid"
},
"tables":[
],
"_ssl":false
}
Here is a sample parameters for Add To Definition:
{
"layers": [
{
"adminLayerInfo": {
"geometryField": {
"name": "geometry",
"srid": 4326
}
},
"allowGeometryUpdates": true,
"capabilities": "Query,Editing,Create,Update,Delete",
"copyrightText": "",
"defaultVisibility": true,
"description": "",
"displayField": "",
"drawingInfo": {
"labelingInfo": null,
"renderer": {
"description": "Tracklog",
"label": "Tracklog",
"symbol": {
"angle": 0,
"color": [
255,
0,
0,
255
],
"outline": {
"color": [
255,
255,
0,
255
],
"width": 1
},
"size": 8,
"style": "esriSMSCircle",
"type": "esriSMS",
"xoffset": 0,
"yoffset": 0
},
"type": "simple"
},
"transparency": 0
},
"extent": {
"spatialReference": {
"wkid": 4326
},
"type": "extent",
"xmax": 180,
"xmin": -180,
"ymax": 90,
"ymin": -90
},
"fields": [
{
"alias": "ObjectID",
"defaultValue": null,
"domain": null,
"editable": false,
"name": "objectid",
"nullable": false,
"type": "esriFieldTypeOID"
},
{
"alias": "GlobalID",
"defaultValue": null,
"domain": null,
"editable": false,
"length": 38,
"name": "globalid",
"nullable": false,
"sqlType": "sqlTypeGUID",
"type": "esriFieldTypeGlobalID"
},
{
"alias": "Latitude",
"domain": null,
"editable": true,
"name": "latitude",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Longitude",
"domain": null,
"editable": true,
"name": "longitude",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Altitude",
"domain": null,
"editable": true,
"name": "altitude",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Easting",
"domain": null,
"editable": true,
"name": "easting",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "Northing",
"domain": null,
"editable": true,
"name": "northing",
"nullable": true,
"type": "esriFieldTypeDouble"
},
{
"alias": "UTC Date & Time",
"domain": null,
"editable": true,
"name": "utcdatetime",
"nullable": true,
"type": "esriFieldTypeDate"
},
{
"alias": "UTC Date",
"domain": null,
"editable": true,
"name": "utcdate",
"nullable": true,
"type": "esriFieldTypeDate"
},
{
"alias": "UTC Time",
"domain": null,
"editable": true,
"length": 20,
"name": "utctime",
"nullable": true,
"type": "esriFieldTypeString"
},
{
"alias": "Sentence",
"domain": null,
"editable": true,
"length": 255,
"name": "sentence",
"nullable": true,
"type": "esriFieldTypeString"
}
],
"geometryType": "esriGeometryPoint",
"globalIdField": "globalid",
"hasAttachments": true,
"hasM": false,
"hasStaticData": false,
"hasZ": false,
"htmlPopupType": "esriServerHTMLPopupTypeAsHTMLText",
"id": 0,
"isDataVersioned": false,
"maxRecordCount": 1000,
"maxScale": 0,
"minScale": 0,
"name": "Tracklog",
"objectIdField": "objectid",
"relationships": [],
"supportedQueryFormats": "JSON",
"supportsAdvancedQueries": true,
"supportsRollbackOnFailureParameter": true,
"supportsStatistics": true,
"templates": [],
"type": "Feature Layer",
"typeIdField": "",
"types": [],
"indexes": [
{
"description": "GlobalID index",
"fields": "globalid",
"isAscending": false,
"isUnique": true,
"name": "GlobalIDIndex"
}
]
}
]
}