Publish Item

Description

Publishes a hosted service based on an existing source item.

Publishers can create feature services as well as tiled map services.

Feature services can be created using input files of type csv, shapefile, serviceDefinition, geojson, sqliteGeodatabase, featureCollection, and fileGeodatabase.

Request Parameters

Parameter

Details

[Common Parameters]

For a complete listing, see Common parameters.

itemID

The ID of the item to be published.

Example: itemId=345313e619df46f387f9ededbe15ac56

file

The file to be uploaded. If uploading a file, the request must be a multipart request pursuant to IETF RFC1867.

text

NoteNote:

Only applicable to CSV and feature collection types.

The text in the file to be published.

Example: text=<text_in_file>

fileType

Item type.

Values: serviceDefinition | shapefile | csv | tilePackage | featureService | featureCollection | fileGeodatabase | geojson | scenepackage | vectortilepackage | imageCollection | mapService | sqliteGeodatabase

NoteNote:

imageCollection applies to Portal for ArcGIS only.

Example: filetype=shapefile

publishParameters

A JSON object describing the service to be created as part of the publish operation. The appropriate value for publish parameters depends on the file type being published.

Example: publishParameters={"name":"Streets"}

outputType

Only used when a feature service is published as a tile service.

Example: outputType=Tiles

overwrite

If true the feature service is overwritten.

//Available in ArcGIS Online and 10.5 Portal for ArcGIS.

NoteNote:

The default value is false.

Values: true | false

Publisher parameters JSON object for CSVs

The publishParameters JSON object used to publish a CSV file is described below.

Parameter

Details

name

(Required)

Name of the service to be created. The same name is reused as the name for the single layer within the service if the layerInfo parameter is not provided.

locationType

(Required)

Values: coordinates | address | lookup | none

When locationType = coordinates, the CSV data contains x,y information.

When locationType = address, the CSV data contains address fields that will be geocoded to a single point.

When locationType = lookup, the CSV data contains fields that can be mapped to well-known sets of geographies.

When locationType = none, the CSV data contains no spatial content and data will be loaded and subsequently queried as tabular data.

Based on this parameter, additional parameters will be required, for example, when specifying locationType = coordinates, the latitude and longitude field names must be specified.

latitudeFieldName

(Required if locationType = coordinates)

If locationType = coordinates, the name of the field that contains the y coordinate.

longitudeFieldName

(Required if locationType = coordinates)

If locationType = coordinates, the name of the field that contains the xcoordinate.

addressTemplate

(Required if locationType = address)

A string value that defines the address to find based on CSV field values.

Example: "{Address} {City}, {State} {Zip}"

lookupType

(Required if locationType = lookup)

The type of place to look up.

lookupFields

(Required if locationType = lookup)

A JSON object with name value pairs that define the fields used to look up the location.

layerInfo

(Required)

A JSON object that provides additional information about the dataset. The JSON format resembles the layerDescriptor used in publishing feature services to an on-premise spatial data server or ArcGIS Server. All parameters except fields are optional.

{ 
{"name" : "<layer name>", 
"type" : "Feature Layer", 
"geometryType" : "<geometry type>", 
"minScale" : <number>, 
"maxScale" : <number>, 
"extent" : {<extent JSON with spatial ref>}, 
"drawingInfo" : {<drawing info JSON>}, 
"hasAttachments" : false, 
"htmlPopupType" : "<popup type>", 
"objectIdField" : "<name of object Id field>", 
"typeIdField" : "<type Id field>", 
"fields" : [<array of field JSON objects>], 
"types" : [<array of type JSON objects>], 
"templates" : [<array of type JSON objects>], 
"capabilities" : "<Query and/or Editing, comma separated>"
}

Certain parameters such as geometryType and extent can be implied or calculated from the dataset.

Primary Key

The objectId field is used as the name of the primary key column. If this field is a non-editable integer, the primary key is also made an auto-incrementing column. If no objectId field is specified, an auto-incrementing column named FID is used.

description

A friendly description for the published dataset.

maxRecordCount

A double value indicating any constraints enforced on query operations.

The default is -1 or int.MaxValue indicating no constraint.

copyrightText

Copyright information associated with the dataset.

columnNames

[array of column names], overridden if layerInfo fields is specified.

If columnNames are omitted, the field names are inferred from the first line in source CSV.

columnDelimiter

A delimiter between data fields in each row of text.

Default is the comma character.

sourceSR

Spatial reference of the input coordinates.

The default is WKID 4326.

targetSR

Target spatial reference of the coordinates as stored in the database.

The default is WKID 102100.

A sample publishParameters JSON object for a CSV is as follows:

{
  "name" : "My CSV File Dataset",
  "locationType" : "coordinates",
  "latitudeFieldName" : "Latitude",
  "longitudeFieldName" : "Longitude",
  "description" : "test description",
  "maxRecordCount" : 500,
  "copyrightText" : "test copyright",
  "sourceSR" : { "wkid" : 4326 },
  "targetSR" : { "wkid" : 4326 },
  "layerInfo" : 
    {
      "name" : "Illinois", 
      "type" : "Feature Layer", 
      "geometryType" : "esriGeometryPoint", 
      "minScale" : 0, 
      "maxScale" : 0,
      "drawingInfo" : {
        "renderer" : 
        {
          "type" : "simple", 
          "symbol" : 
          {
            "type" : "esriSMS", 
            "style" : "esriSMSDiamond", 
            "color" : [
              115, 
              76, 
              0, 
              255
            ], 
            "size" : 8, 
            "angle" : 0, 
            "xoffset" : 0, 
            "yoffset" : 0, 
            "outline" : 
            {
              "color" : [
                152, 
                230, 
                0, 
                255
              ], 
              "width" : 1
            }
          }, 
          "label" : "test label", 
          "description" : "test description"
        }, 
        "transparency" : 0, 
        "labelingInfo" : null
      }, 
      "hasAttachments" : false, 
      "htmlPopupType" : "esriServerHTMLPopupTypeNone", 
      "objectIdField" : "GeographyId", 
      "globalIdField" : "", 
      "typeIdField" : "", 
      "fields" : [
        {
          "name" : "GeographyId", 
          "type" : "esriFieldTypeInteger", 
          "alias" : "FID", 
          "sqlType" : "sqlTypeInteger", 
          "nullable" : false, 
          "editable" : false, 
          "domain" : null
        }, 
        {
          "name" : "GeographyName", 
          "type" : "esriFieldTypeString", 
          "alias" : "Geog Name", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "GeographyType", 
          "type" : "esriFieldTypeString", 
          "alias" : "Geog type", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "StateAbbreviation", 
          "type" : "esriFieldTypeString", 
          "alias" : "State Abbr.", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "StateFipsCode", 
          "type" : "esriFieldTypeInteger", 
          "alias" : "FIPS", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "StateName", 
          "type" : "esriFieldTypeString", 
          "alias" : "State", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "CountyFipsCode", 
          "type" : "esriFieldTypeString", 
          "alias" : "County Fips", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "Longitude", 
          "type" : "esriFieldTypeDouble", 
          "alias" : "Longitude", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }, 
        {
          "name" : "Latitude", 
          "type" : "esriFieldTypeDouble", 
          "alias" : "Latitude", 
          "nullable" : false, 
          "editable" : true, 
          "domain" : null
        }
      ], 
      "types" : [], 
      "templates" : [], 
      "capabilities" : "Query,Editing"
    }
}

Publish parameters JSON object for shapefiles, feature collections, and file geodatabases

The publishParameters JSON object used to publish shapefiles, feature collections, and file geodatabases is described below.

Parameter

Details

name

Name of the published service. The same name is reused as the name for the single layer within the service if the layerInfo parameter is not provided.

description

A friendly description for the published dataset. The same description is reused for the single layer within the service if the layerInfo parameter is not provided.

maxRecordCount

A double value indicating any constraints enforced on query operations.

The default is -1 or int.MaxValue indicating no constraint.

copyrightText

Copyright information associated with the dataset.

layerInfo

A JSON object that provides additional information about the dataset. The JSON format resembles the layerDescriptor used in publishing feature services to an on-premise spatial data server or ArcGIS Server.

{"name" : "<layer name>",  
"type" : "Feature Layer", 
"description" : "<description>", 
"copyrightText" : "<copyright text>", 
"geometryType" : "<geometry type>", 
"minScale" : <number>, 
"maxScale" : <number>, 
"extent" : {<extent JSON with spatial ref>}, 
"drawingInfo" : {<drawing info JSON>}, 
"hasAttachments" : false, 
"htmlPopupType" : "<popup type>", 
"objectIdField" : "<object Id field>", 
"globalIdField" : "", 
"typeIdField" : "<type Id field>", 
"fields" : [<array of field JSON objects>], 
"types" : [<array of type JSON objects>], 
"templates" : [<array of type JSON objects>], 
"capabilities" : "<Query and/or Editing, comma separated>"
}
targetSR

Target spatial reference of the geometries as stored in the database.

The default is WKID 102100.

A sample publishParameters JSON object for publishing shapefiles, feature collections, and file geodatabases is as follows:

{
  "name" : "Name of published result",
  "description" : "test description",
  "maxRecordCount" : 500,
  "copyrightText" : "test copyright",
  "targetSR" : { "wkid" : 4326 },
  "layerInfo" : 
    {
      "name" : "States From File", 
      "type" : "Feature Layer", 
      "geometryType" : "esri GeometryPolygon", 
      "minScale" : 0, 
      "maxScale" : 0,
      "drawingInfo" : {
        "renderer" : 
        {
          "type" : "simple", 
          "symbol" : 
          {
            "type": "esriSFS",
            "style": "esriSFSSolid",
            "color": [115,76,0,255],
            "outline": {
              "type": "esriSLS",
              "style": "esriSLSSolid",
              "color": [110,110,110,255],
              "width": 1
            }
          }
        },
        "transparency" : 0, 
        "labelingInfo" : null
      }, 
      "htmlPopupType" : "esriServerHTMLPopupTypeNone", 
      "fields" : [], 
      "capabilities" : "Query,Editing"
    }
}

Publishing from a service definition (.sd), tile package (.tpk) file or vector tile package (.vtpk) item

publishParameters are optional when publishing a service definition (.sd), vector tile package (.vtpk), or tile package (.tpk) file.

Response Properties

Property

Details

type

The resulting item is a feature service, map service, or vector tile service URL item.

serviceURL

The URL to the hosted feature, map service, or vector tile service.

size

The approximate size required for the service.

jobId

The job ID of the publishing process. All publishing operations are executed asynchronously. The caller is supposed to hold on to the job ID and check for job status of the job. The status can be checked using Status passing in jobType as a query parameter; for example jobType=publish.

serviceItemId

The ID of the new service item.

preserveEditUsersAndTimestamps

The preserveEditUsersAndTimestamps parameter allows the user to preserve editor tracking info of the users and timestamps while publishing online.

NoteNote:

The default is not to preserve editor tracking info.

Example: {"editorTrackingInfo":{"enableEditorTracking":true,"preserveEditUsersAndTimeStamps":true}}

Publishing a tile service from an existing feature service

Property

Details

type

The resulting item is a map service URL item.

serviceURL

The URL to the hosted feature or map service.

jobId

The job ID of the publishing process. All publishing operations are executed asynchronously. The caller is supposed to hold on to the job ID and check for job status of the job. The status can be checked using Status passing in jobType as a query parameter; for example, jobType=publish .

serviceItemId

The ID of the new service item.

Example Usage - Shapefile

URL for Publish Item

http://www.arcgis.com/sharing/rest/content/users/jsmith/publish
itemId=345313e619df46f387f9ededbe15ac56
filetype=shapefile
publishParameters={"name":"Streets Service"}

Example Usage - Vector Tile Package

URL for Publish Item

http://www.arcgis.com/sharing/rest/content/users/jsmith/publish
f=json
token=xxx
itemId=345313e619df46f387f9ededbe15ac56
filetype=vectortilepackage
publishParameters={"name":<"SampleBasemap">,"maxRecordCount":2000}
outputType=VectorTiles
buildInitialCache=true

JSON Response Syntax

{"services": [{"type":"<type of service>", 
"serviceurl":"<url to hosted service>",
"size":<size of service>,
"jobId":"<job id>",
"serviceItemId":"<new item id>"}]}

JSON Response Example

{"services":
[{"type":"Feature Service",
"serviceurl":"http://www.arcgis.com/fa019fbbfbb845d08cc9f0acde6dd8af/arcgis/rest/services/
Streets_Service/FeatureServer",
"size":2656729,
"jobId":"ff07c87a-dccd-46b4-9597-446dcda248ff",
"serviceItemId":"2e39b0b9550a40709f02a697cd9fc4fb"}]}

3/3/2017