Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

HTTPError: HTTP Error 404: Not Found #273

Closed henry296 closed 7 years ago

henry296 commented 8 years ago

I used the append features from feature class sample to build a script. It works fine with point features, but when I try to upload 745 polygon features, I get this error: HTTPError: HTTP Error 404: Not Found when executing the fl.addFeatures step. Here is the code. The itemID is defined earlier in the code because I first delete all of the features.

I download from GitHub about a month ago.

db_fc = "Database Connections\Connection to SQL12-P-0301.sde\MarketResearch.DBO.Location" HostedServices_gdb = "S:\Market Research\ESRI\HostedServices.gdb" layerName = "ExistingStoreTradeAreasHosted" #Layer name on ArcGIS Online to load data

print "Feature Class Created"
fc="S:\\Market Research\ESRI\\HostedServices.gdb\\ExistingStoreTradeAreasHosted" #Path to Feature Class
atTable=None
try:
    fst_load = featureservicetools.featureservicetools(securityinfo)
    if fst_load.valid == False:
        print fst_load.message
    else:

        fs_load = fst_load.GetFeatureService(itemId=itemId,returnURLOnly=False)
        if not fs_load is None:

            fl = fst_load.GetLayerFromFeatureService(fs=fs_load,layerName=layerName,returnURLOnly=False)
            if not fl is None:
                **results = fl.addFeatures(fc=fc,attachmentTable=atTable)**
                print json.dumps(results)
                print "Layer is copied to ArcGIS Online"
            else:
                print "Layer %s was not found, please check your credentials and layer name" % layerName
        else:
            print "Feature Service with id %s was not found" % fsId

except:
    line, filename, synerror = trace()
    print "error on line: %s" % line
    print "error in file name: %s" % filename
    print "with error message: %s" % synerror

ArcRest or ArcRestHelper

Version or date of download

Bug or Enhancement

Repo Steps or Enhancement details

henry296 commented 7 years ago

I switched to using the AddFeaturesToFeautreLayer tool from the Add features to service sample instead of the AddFeatures from the append to feature class sample so I could specific a chunk size. I'm still getting the HTTP 404 error from this section of code: try: fst = featureservicetools.featureservicetools(securityinfo) if fst.valid == False: print fst.message else:

        fs = fst.GetFeatureService(itemId=itemId,returnURLOnly=False)
        if not fs is None:

            fs_url = fst.GetLayerFromFeatureService(fs=fs,layerName=layerName,returnURLOnly=True)
            if not fs_url is None:
                results =  fst.AddFeaturesToFeatureLayer(url=fs_url, pathToFeatureClass=fc,
                                                  chunksize=1000)
                if 'addResults' in results:
                    print "%s features processed" % len(results['addResults'])
henry296 commented 7 years ago

I figured out how to use the chunk size. Since I had the chunk size at 1000 it was trying to load all of the features in a single load. I changed it to 1 and it loaded each feature one at a time. I will try to find the right sweet spot for this feature class.