Pretty sure this will enable attachments, it works for me. Update variables at the bottom. You can switch TRUE to FALSE to disable attachments.import json, urllib, urllib2
def gentoken(username, password, referer, expiration=60):
#Re-usable function to get a token required for Admin changes
referer = "http://www.arcgis.com/"
query_dict = {'username': username,
'password': password,
'expiration': str(expiration),
'client': 'referer',
'referer': referer,
'f': 'json'}
query_string = urllib.urlencode(query_dict)
tokenUrl = "https://www.arcgis.com/sharing/rest/generateToken"
tokenResponse = urllib.urlopen(tokenUrl, urllib.urlencode(query_dict))
token = json.loads(tokenResponse.read())
if "token" not in token:
print token['messages']
import sys
sys.exit()
else:
# Return the token to the function which called for it
return token['token']
def enableAttachment(token, fsURL):
query_dict = {'updateDefinition': "{'hasAttachments':true}", #false
'f': 'json',
'token': token}
query_string = urllib.urlencode(query_dict)
attachResponse = urllib.urlopen(fsURL, urllib.urlencode(query_dict))
msg = json.loads(attachResponse.read())
print msg
return
USERNAME = " ______ "
PASSWORD = " ______ "
REFFER = "http://www.arcgis.com"
fsURL = "http://services1.arcgis.com/<ORGANIZATION IDENTFIER/arcgis/admin/services/<SERVICE NAME>.FeatureServer/0/updateDefinition"
# for example, a link may look like:
#http://services1.arcgis.com/4safsf2dgg32daf3/arcgis/admin/services/MyService.FeatureServer/0/updateDefinition
token = gentoken(USERNAME, PASSWORD, REFFER)
enableAttachment(token, fsURL)