TW_WebMap

ArcGIS REST unable to updateDefinition

Discussion created by TW_WebMap on Feb 14, 2018
Latest reply on Feb 14, 2018 by TW_WebMap

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/updateDefinition"
#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

Outcomes