AnsweredAssumed Answered

Creating views from feature service doesn't include Tables

Question asked by antti.kajanus_CGISuomi on Jan 9, 2020

Currently flc.manager.create_view(...) doesn't seem to publish any tables that are part of the service. Is there a way to do that using the API with some other parameters,etc? I have tried to use view_layers explicitly defining the layer as well but it doesn't seem to make any difference. Ideas?

 

from arcgis.gis import GIS
import getpass

password = getpass.getpass("Enter password: ")

gis = GIS('organization', 'username', password)
print("Connected to: {}\nConnected as: {}".format(
                                                 gis.properties.urlKey + "." + gis.properties.customBaseUrl,
                                                 gis.users.me.username))

folder_name = 'TestFolder'
folder = gis.content.create_folder(folder=folder_name)
folder

created_item = gis.content.add(
        item_properties={
            'title' : 'Test',
            'type' : 'Service Definition',
            'tags' : ['TEST'],
        },
        folder = folder_name,
        data= r'./data-publish/HSLCityBikes.sd')

published_service_item = created_item.publish()
published_service_item.update(thumbnail="./data-publish/esriDefaultMarker_189_Green.png")
published_service_item

from arcgis.features import FeatureLayerCollection

capabilities = "Query"
title = published_service_item.title + " (ReadOnly)"

flc = FeatureLayerCollection.fromitem(published_service_item)
created_view_item = flc.manager.create_view(name=title, capabilities = capabilities)
created_view_item.move(folder=folder_name)

 

Original service

 

Created view

Outcomes