Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

ArcREST addItem error in ArcGIS Online #53

Closed
geoffreywestGIS opened this issue May 6, 2015 · 2 comments
Closed

ArcREST addItem error in ArcGIS Online #53

geoffreywestGIS opened this issue May 6, 2015 · 2 comments

Comments

@geoffreywestGIS
Copy link

When accessing the added item in AGOL a general error message appears i.e
It is a CSV; the error that is returned

Error retrieving file from http://myorg.maps.arcgis.com/sharing/content/items/a935aa00f237477ba9912ca2bd32b79d/data?token=AYJwMLSoVIlx7LzbY_vcFNMb9yZ6wyutOARMXSKQd21g17xNE96bqzMBns97ySZlYr2nXVhAHBWxldT57NKS5HCL1i8xFyDYVLPBoVzZqer1VzcbeOVSBSdo8xzoCyzWRY8b5iNRKhow4oeD6Mlg5w..

The item adds to AGOL but does not allow users to publish or download.
Perhaps this has something to do with issue # 52.

import arcrest

if name == "main":
username = ""
password = ""
portalId = ""
url = ""
thumbnail_url = ""
kml_path = "C:\Users\GeoffreyWest\Desktop\aCSV.CSV"
securityHandler = arcrest.AGOLTokenSecurityHandler(username,
password)
# Create the administration connection
#
admin = arcrest.manageorg.Administration(url, securityHandler)
# Connect to the portal
#
portal = admin.portals(portalId)
# Access the content properties to add the item
#
content = admin.content
# Provide the item parameters
#

itemParams = arcrest.manageorg.ItemParameter()
itemParams.thumbnailurl = thumbnail_url
itemParams.title = "aCSV"
itemParams.type = "CSV"
itemParams.tags = "aCSVTest,CSV,test"
#   Enter in the username you wish to load the item to
#
usercontent = content.usercontent(username=username)
print usercontent.addItem(filePath=kml_path,
                          itemParameters=itemParams)
@achapkowski
Copy link
Collaborator

What type of item is it?
Can you please post your code?

Thank you

@achapkowski
Copy link
Collaborator

Please see the sample below and pull the latest. This publishes without error.

import arcrest

if __name__ == "__main__":
    username = "some username"
    password = "some secure password"
    csv_file = r"C:\temp\book1.csv"

    sh = arcrest.AGOLTokenSecurityHandler(username, password)
    admin = arcrest.manageorg.Administration(securityHandler=sh)
    content = admin.content
    usercontent = content.usercontent(username=username)
    ip = arcrest.manageorg.ItemParameter()
    ip.title = "Sample CSV"
    ip.type = "CSV"
    ip.tags = "tag1,tag3"
    ip.overwrite = True
    ip.thumbnailurl = r"http://php-addict.com/wp-content/uploads/2015/01/csv-xxl.png"
    res = usercontent.addItem(itemParameters=ip,
                              filePath=csv_file)
    itemId = res['id']

    #  Now you need to analyze the item to publish it
    #
    featureContent = content.featureContent
    analyzeParams = arcrest.manageorg.AnalyzeParameters()
    analyzeResult = featureContent.analyze(itemId=itemId, analyzeParameters=analyzeParams)
    #  Published based off the analyze function
    #
    if 'publishParameters' in analyzeResult:
        pp = analyzeResult['publishParameters']
        publishParams = arcrest.manageorg.PublishCSVParameters(name=pp['name'],
                                               locationType=pp['locationType'],
                                               layerInfo=pp['layerInfo'],
                                               latitudeFieldName=pp["latitudeFieldName"],
                                               longitudeFieldName=pp['longitudeFieldName'])
        print usercontent.publishItem(fileType="csv",
                                      publishParameters=publishParams,
                                      itemId=itemId)
    print 'finished'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants