Select to view content in your preferred language

ArcGIS REST unable to updateDefinition

1589
1
02-14-2018 12:53 PM
KevinAndras
Emerging Contributor

Hi, using the REST API, I'm attempting to update multiScaleGeometryInfo for my feature layers, but I'm having trouble getting into the updateDefinition URL. Here's the error I get:

{u'error': {u'message': u'Unable to update feature service layer definition.', u'code': 400, u'details': [u'Value cannot be null. Parameter name: input']}}

Here's my Python script.  Thanks for any help!

import sys
import ntpath
import os, sys, json, urllib, urllib2, httplib, urlparse, mimetools, mimetypes
from cStringIO import StringIO

username = "un"
password = "pw"

tokenURL = "https://www.arcgis.com/sharing/generateToken"
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://services7.arcgis.com'}
req = urllib2.Request(tokenURL, urllib.urlencode(params))
try:
   response = urllib2.urlopen(req)
except:
   gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
   response = urllib2.urlopen(req, context=gcontext)
data = json.load(response)
token = data['token']
print(token)
requesturl = "https://services7.arcgis.com/[ID]/ArcGIS/rest/admin/services/example/FeatureServer/0/updateDefinitio..."
#data = {'f': 'json', 'token': sh.token, "multiScaleGeometryInfo" : {"levels" : [7,9,11,13,15]}}  #this is what I'll eventually do
data = { "f": "json", "token": token}
query_string = urllib.urlencode(data)
print query_string

response = urllib.urlopen(requesturl, query_string)
resp_json = json.loads(response.read())
print resp_json

0 Kudos
1 Reply
KevinAndras
Emerging Contributor

I figured it out.  Need to have async=true, and add the updateDefinition parameter.

This is the corrected line:

data = { "f": "json", "token": token, "async": "true", "updateDefinition": {"multiScaleGeometryInfo": {"levels" : [7,9,11,13,15]}}}