Select to view content in your preferred language

Enable Time Settings of Feature Service

1600
2
Jump to solution
03-08-2019 02:34 AM
KarstenRank
Frequent Contributor

Hi there,

is it possible to enable to the "Time Settings" of a Feature Service with the Python API?

Thanks for your help

Karsten

1 Solution

Accepted Solutions
KarstenRank
Frequent Contributor

Find the solution:

  • first create a token
  • updateServiceDef

def updateServiceDef(token):
    ''' use this to update feature service max record count '''
    updateServiceDefURL = 'https://services2.arcgis.com/.../ArcGIS/rest/admin/services/.../FeatureServer/0/updateDefinition'
    params = {
      'updateDefinition': {"timeInfo" : {"startTimeField" : "DateTimeField1", "endTimeField" : "DateTimeField2"}},
        'async': 'true',
      'token': token,
      'f':'json'
    }
    response = requests.post(updateServiceDefURL, data=params, verify=True)

View solution in original post

2 Replies
KarstenRank
Frequent Contributor

Find the solution:

  • first create a token
  • updateServiceDef

def updateServiceDef(token):
    ''' use this to update feature service max record count '''
    updateServiceDefURL = 'https://services2.arcgis.com/.../ArcGIS/rest/admin/services/.../FeatureServer/0/updateDefinition'
    params = {
      'updateDefinition': {"timeInfo" : {"startTimeField" : "DateTimeField1", "endTimeField" : "DateTimeField2"}},
        'async': 'true',
      'token': token,
      'f':'json'
    }
    response = requests.post(updateServiceDefURL, data=params, verify=True)

ThomasParisi
New Contributor

You should be able to do this with manager.update_definition() as well

lyr = gis.content.get('{your Feature Layer item id}').layers[0]
lyr.manager.update_definition({ 
  "timeInfo": {
    "startTimeField": "{your Start date/time field}",
    "endTimeField": "{your End date/time field}"
  }
})

https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm - This reference has plenty of other examples for Service Definition updates you can make with this function.

0 Kudos