<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JSON.Load python file -- Add Features to Feature Service in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334961#M9097</link>
    <description>&lt;P&gt;Are you certain the problem is on the json.loads side? When you load from the files, does the count match what you expect? I suspect the problem is actually on the append side.&lt;/P&gt;&lt;P&gt;I've encountered similar issues in the past when attempting to add several thousand records all at once. My solution was to apply the edits in batches (of 500 or so).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 15:17:52 GMT</pubDate>
    <dc:creator>EarlMedina</dc:creator>
    <dc:date>2023-10-04T15:17:52Z</dc:date>
    <item>
      <title>JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334915#M9094</link>
      <description>&lt;P&gt;I have a service that I am scrapping via Python that I am scrapping in Chucks do to the size of the dataset... about 12,000 records&lt;/P&gt;&lt;P&gt;During this scrape it writes the values to individual JSON files 1000 records at a time.&amp;nbsp; I can open these JSON files and see there is an OBJECTID =1 and then OBJECTID=1000 and then the next one is OBJECTID=1001 and OBJECTID=2000 etc etc...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can Copy that contents of that JSON file and put it in the REST Services and update from there with NO issues.. so I know the format is correct.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kapalczynski_0-1696426963663.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82271i7033DCEF71096418/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kapalczynski_0-1696426963663.png" alt="kapalczynski_0-1696426963663.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I read somewhere that there is a limit on characters of the JSON.Load&amp;nbsp; which I am trying in the second def below.&amp;nbsp; My files are about 830 KB in size...it appears not all of them are getting in... as I only get about 4300 of the 12k records in the Append Process...&lt;/P&gt;&lt;P&gt;Good news is that it does NOT Error out.&amp;nbsp; But simply does not append all the records.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there is a limitation on the JSON.Load how do I get around it... I tried to decrease the 1000 record count in my code to make more files but that does not seem to work... Im puzzled...&lt;BR /&gt;&lt;BR /&gt;Thoughts?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;def scrapeData(out_json_path, out_fc_path):
    try:
        service_props = ds.getServiceProperties(ds.service_url)
        max_record_count = 1000
        layer_ids = ds.getLayerIds(ds.service_url)
        id_groups = list(ds.chunks(layer_ids, max_record_count))
        for i, id_group in enumerate(id_groups):
            print('  group {} of {}'.format(i+1, len(id_groups)))
            layer_data = ds.getLayerDataByIds(ds.service_url, id_group)
            level = str(i)
            outjsonpath = outputVariable + level + ".json"
            if i==0: # If first iteration of id_groups
                layer_data_final = layer_data
                with open(outjsonpath, 'w') as out_json_file:
                        json.dump(layer_data_final, out_json_file)
            else:
                layer_data_final2 = layer_data
                with open(outjsonpath, 'w') as out_json_file:
                        json.dump(layer_data_final2, out_json_file)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then loop through the JSON files and Append them to the Feature Service&lt;/P&gt;&lt;LI-CODE lang="c"&gt;def addDEQData():
    for x in os.listdir(path):
        if x.startswith("output"):
            filetoImport = path + x
            f = open(filetoImport)
            data = json.load(f)
            featureAddingAdd = data['features']
            gis_payloadAdd = {
                'token': currenttoken,
                'f': 'json',
                'features': f'''{featureAddingAdd}'''
                }
            urlAdd = urlADDFeatures
            files=[]
            headers = {}
            response = requests.request("POST", urlAdd, headers=headers, data=gis_payloadAdd, files=files)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 13:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334915#M9094</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-04T13:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334916#M9095</link>
      <description>&lt;P&gt;Note I am doing it this way at REST Service due to issues with Servers and .sde connection files... I am not looking to hit the Oracle server and use sde connection files with a Truncate and Append...&amp;nbsp;Its slower anyways...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 13:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334916#M9095</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-04T13:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334938#M9096</link>
      <description>&lt;P&gt;I think I found it... testing now.&lt;/P&gt;&lt;P&gt;EDIT..... Nope still only 4500 or so out of the 12k&lt;/P&gt;&lt;P&gt;Crazy thing is .... the JSON files have to correct number of records in them only 200 as I specified and I can see a ton more JSON files being created... but for some reason no more records are being added with the Append.... very puzzling&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 14:58:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334938#M9096</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-04T14:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334961#M9097</link>
      <description>&lt;P&gt;Are you certain the problem is on the json.loads side? When you load from the files, does the count match what you expect? I suspect the problem is actually on the append side.&lt;/P&gt;&lt;P&gt;I've encountered similar issues in the past when attempting to add several thousand records all at once. My solution was to apply the edits in batches (of 500 or so).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 15:17:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334961#M9097</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-04T15:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334973#M9098</link>
      <description>&lt;P&gt;Yea Im very confused...&amp;nbsp;&lt;/P&gt;&lt;P&gt;So when I scrape the Data and write to JSON files I get about 224 of them... This is set to CHUNKS of 100 records...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have set the CHUNKS to about 100 records per JSON File.. As you can see below I am Loading each JSON file -- Grabbing the 'features' key and then using a POST to past this data.&lt;/P&gt;&lt;P&gt;As you can see from the 2nd image below which is showing the 224th JSON file you can see the OBJECTID of 24,401&lt;/P&gt;&lt;P&gt;If I manually copy the JSON and paste it into the AddFeatures of Rest -- 3rd Image below it adds the 100 records with no issues... I can even do this with 1000 records ... the only reason I went down to 100 was to test if this was an issue... the JSON being to large.&lt;/P&gt;&lt;P&gt;So right up until I Append the Records the JSON file has the 100 records + 224 JSON files which is the 24,000+ records I am trying to add... so EVERYTHING seems good to go...&lt;/P&gt;&lt;P&gt;BUT only a 1/6 or so of the records make it....&lt;/P&gt;&lt;LI-CODE lang="c"&gt;            f = open(filetoImport)
            data = json.load(f)
            featureAddingAdd = data['features']
            print(featureAddingAdd)
            gis_payloadAdd = {
                'token': currenttoken,
                'f': 'json',
                'features': f'''{featureAddingAdd}'''
                }
            urlAdd = urlADDFeatures
            files=[]
            headers = {}
            response = requests.request("POST", urlAdd, headers=headers, data=gis_payloadAdd, files=files)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kapalczynski_0-1696433227605.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82284i60138425E47F6910/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kapalczynski_0-1696433227605.png" alt="kapalczynski_0-1696433227605.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kapalczynski_1-1696433427695.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82286i56A36B0C7615A5B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kapalczynski_1-1696433427695.png" alt="kapalczynski_1-1696433427695.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 15:33:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1334973#M9098</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-04T15:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335018#M9100</link>
      <description>&lt;P&gt;Just an observation - I don't know if it's significant - but one difference between the two methods is the header. Maybe looking into the differences between the two requests could yield some useful information.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 16:41:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335018#M9100</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-04T16:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335032#M9101</link>
      <description>&lt;P&gt;OK so the JSON Files seem to be being created ok as they seem to only have 100 records in them like expected.&lt;/P&gt;&lt;P&gt;When I load the Json files I put 2 prints there and when I look it appears that there are also 100 features there in the Features KEY.&amp;nbsp; So that looks good as well.&lt;/P&gt;&lt;P&gt;I stripped all the JSON files except one and then re ran and ONLY 19 records were added to the Feature Class. hmmmmm&amp;nbsp;&lt;/P&gt;&lt;P&gt;SO its leaning towards the Requests.request it appears....something is not right there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Crazy is that I can grab the Parameter values from "featureAddingAdd" from the code below Copy and Paste the Json into Rest Services Add Feature and it adds all 100 records no issues&lt;/P&gt;&lt;P&gt;But the request below that uses the same variable json values ONLY adds 19 records.... what gives.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;            print("Appending: " + x)
            f = open(filetoImport)
            data = json.load(f)
            featureAddingAdd = data['features']
            print(featureAddingAdd)
            gis_payloadAdd = {
                'token': currenttoken,
                'f': 'json',
                'features': f'''{featureAddingAdd}'''
                }
            print("-------")
            print(gis_payloadAdd)
            urlAdd = urlADDFeatures
            files=[]
            headers = {}
            response = requests.request("POST", urlAdd, headers=headers, data=gis_payloadAdd, files=files)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 18:45:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335032#M9101</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-04T18:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335108#M9103</link>
      <description>&lt;P&gt;I tried this way as well and still only get 19 of the 100 records from the JSON file being added... ugggg&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;resp = requests.post(urlAdd, gis_payloadAdd)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I can return the value of the variable "featureAddingAdd" and it has all 100 records in it ... its not the json.load that seems to be the issue... it looks like the request post Append that is going on...&amp;nbsp;&lt;/P&gt;&lt;P&gt;It only adds 19 records but I can copy the json from the variable above and go to Rest Services Add Feature and post the json code and it adds all 100 records...&amp;nbsp;&lt;/P&gt;&lt;P&gt;ugggggggggggggggg&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 19:01:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335108#M9103</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-04T19:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335179#M9106</link>
      <description>&lt;P&gt;Out of curiosity have you attempted the equivalent workflow using the ArcGIS API for Python? I realize you may have your reasons for using the REST API directly, but thought I would ask in case there's a possibility that might work better. The Python API will be a little different through the use of requests.Session (I'm pretty sure) and headers. I'm certain there is some configuration that is missing here that is giving you these odd results.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 01:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335179#M9106</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-05T01:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335395#M9107</link>
      <description>&lt;P&gt;I need to do the Append data via REST API where I do not have to have a .sde connection file... if there is another way to do this without an SDE connection file / DB permissions then that would be great...&amp;nbsp;&lt;/P&gt;&lt;P&gt;So puzzled why only 20% of the features get through&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If I build the JSON files where they have 1000 records in them it appends 200&lt;/LI&gt;&lt;LI&gt;If I build the JSON files where they have 100 records in them it appends 19&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Does not seem to be the REST itself as I can copy the JSON into the REST webpage and it appends all 1000 or 100 with no issues..&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears to be the request statement where for some reason it only appends about 20% of the records in the JSON file&lt;/P&gt;&lt;P&gt;I will paste all my code below in a few if anyone can see anything....&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 14:55:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335395#M9107</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-05T14:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335403#M9108</link>
      <description>&lt;LI-CODE lang="c"&gt;import arcpy
import arcgis
from arcgis import GIS
import requests
import json
import os

targetURL = "https://apps.deq.virginia.gov/arcgis/rest/services/public/EDMA/MapServer/102"
gis = GIS("https://xxxxxxx/portal", "username", "password")
currenttoken = gis._con.token

urlADDFeatures = r"https://xxxxxx/env/rest/services/DEV/VDEQ_Petro_Tank_Facility_DEV/FeatureServer/0/addFeatures"
urlDeleteFeatures = r"https://xxxxxx/env/rest/services/DEV/VDEQ_Petro_Tank_Facility_DEV/FeatureServer/0/deleteFeatures"

osPath = os.path.dirname(os.path.abspath(__file__))
outputVariable = osPath + "\\PetroleumTankFacilities\\output"
path = osPath + "\\PetroleumTankFacilities\\"

arcpy.env.overwriteOutput = True

class DataScraper():
    def __init__(self):
        # URL to map service you want to extract data from
        self.service_url = targetURL
    def getServiceProperties(self, url):
        URL = url
        PARAMS = {'f' : 'json'}
        r = requests.get(url = URL, params = PARAMS)
        service_props = r.json()
        return service_props
    def getLayerIds(self, url, query=None):
        URL = url + '/query'
        PARAMS = {'f':'json', 'returnIdsOnly': True, 'where' : '1=1'}
        if query:
            PARAMS['where'] = "ST = '{}'".format(query)
        r = requests.get(url = URL, params = PARAMS)
        data = r.json()
        return data['objectIds']
    def getLayerDataByIds(self, url, ids):
        # ids parameter should be a list of object ids
        URL = url + '/query'
        field = 'OBJECTID'
        value = ', '.join([str(i) for i in ids])
        PARAMS = {'f': 'json', 'where': '{} IN ({})'.format(field, value), 'returnIdsOnly': False,
                  'returnCountOnly': False,'returnGeometry': True, 'outFields': '*'}
        r = requests.post(url=URL, data=PARAMS)
        layer_data = r.json()
        return layer_data
    def chunks(self, lst, n):
        # Yield successive n-sized chunks from list
        for i in range(0, len(lst), n):
            yield lst[i:i + n]
            
#def scrapeData(out_json_path, out_fc_path):
def scrapeData():
    try:
        service_props = ds.getServiceProperties(ds.service_url)
        max_record_count = service_props['maxRecordCount']
        layer_ids = ds.getLayerIds(ds.service_url)
        
        # RETURN 1000 Records
        id_groups = list(ds.chunks(layer_ids, max_record_count))
        # RETURN 100 Records
        #id_groups = list(ds.chunks(layer_ids, 100))
        
        for i, id_group in enumerate(id_groups):
            print('  group {} of {}'.format(i+1, len(id_groups)))
            layer_data = ds.getLayerDataByIds(ds.service_url, id_group)
            level = str(i)
            outjsonpath = outputVariable + level + ".json"
            if i==0: # If first iteration of id_groups
                print(outjsonpath)
                print(outshapefilepath)
                layer_data_final = layer_data
                print('Writing JSON file...')
                with open(outjsonpath, 'w') as out_json_file:
                        json.dump(layer_data_final, out_json_file)
            else:
                print(outjsonpath)
                print(outshapefilepath)
                layer_data_final2 = layer_data
                print('Writing JSON file...')
                with open(outjsonpath, 'w') as out_json_file:
                        json.dump(layer_data_final2, out_json_file)
    except Exception:
        # Handle errors accordingly...this is generic
        tb = sys.exc_info()[2]
        tb_info = traceback.format_tb(tb)[0]
        pymsg = 'PYTHON ERRORS:\n\tTraceback info:\t{tb_info}\n\tError Info:\t{str(sys.exc_info()[1])}\n'
        msgs = 'ArcPy ERRORS:\t{arcpy.GetMessages(2)}\n'
        print(pymsg)
        print(msgs)

def deleteDEQData():
    print("Starting to Delete")
    url = urlDeleteFeatures
    whereclause='1=1'
    gis_payload = {
        'token': currenttoken,
        'f': 'json',
        'where': f'''{whereclause}'''
        }
    response = requests.request("POST", url=url, data=gis_payload)
    print("Done Deleting")

def addDEQData():
    print("Starting to Append")
    for x in os.listdir(path):
        if x.startswith("output"):
            filetoImport = path + x
            print("Appending: " + x)
            f = open(filetoImport)
            data = json.load(f)
            featureAddingAdd = data['features']
            print(featureAddingAdd)
            gis_payloadAdd = {
                'token': currenttoken,
                'f': 'json',
                'features': f'''{featureAddingAdd}'''
                }
            print("-------")
            print(gis_payloadAdd)
            urlAdd = urlADDFeatures
            files=[]
            headers = {}
            
            #response = requests.request("POST", urlAdd, headers=headers, data=gis_payloadAdd, files=files)
            #response = requests.request("POST", urlAdd, data=gis_payloadAdd)
            #print(response)
            resp = requests.post(urlAdd, gis_payloadAdd)
            print(resp)
            
if __name__ == '__main__':
        
    # Instantiate DataScraper class
    ds = DataScraper()
    
    # Run the function to get your data
    scrapeData()
    deleteDEQData()
    addDEQData()
    
    print("Done Appending")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 05 Oct 2023 15:00:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335403#M9108</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-05T15:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335434#M9109</link>
      <description>&lt;P&gt;Okay, I think maybe I understand. You might be confusing ArcPy with the ArcGIS API for Python? For ArcPy you would most likely edit data directly using an sde connection file.&lt;/P&gt;&lt;P&gt;The&amp;nbsp;ArcGIS API for Python, on the other hand, is just a wrapper for the REST API that makes it easier to use. I guess the only way you wouldn't be able to use it for this purpose is if you are working with a standalone ArcGIS Server. Otherwise, you would simply log into your portal, load the target Feature Layer, and use the FeatureLayer object's "edit_features" method to accomplish a similar result.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 15:50:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335434#M9109</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-05T15:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335470#M9111</link>
      <description>&lt;P&gt;Not sure what you are getting at... is my approach doable?&amp;nbsp; I mean why does it add 19 of 100 records and 200 of 1000 records and just stop appending?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 16:58:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335470#M9111</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-05T16:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335482#M9112</link>
      <description>&lt;P&gt;From your sample, you're already using the api for login purposes. Why don't you give the edit_features method a shot with your json and see if that produces different results? I don't observe the same behavior using just the API, so I think at least part of the problem may be missing headers.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 17:16:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335482#M9112</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-05T17:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335645#M9113</link>
      <description>&lt;P&gt;Not sure how to do this...&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;Why don't you give the edit_features method a shot with your json&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you have an example... does this work without an SDE connection file?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What would be missing in the headers?&amp;nbsp; Parameters?&amp;nbsp; Not sure there.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 00:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335645#M9113</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-06T00:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335651#M9115</link>
      <description>&lt;P&gt;There's some examples here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/guide/editing-features/" target="_blank"&gt;Editing Features | ArcGIS API for Python.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;No SDE connection required. Your code would change to something like this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcgis
from arcgis.features import FeatureLayer

gis = GIS("https://xxxxxxx/portal", "username", "password")
fl_url = "https://xxxxxx/env/rest/services/DEV/VDEQ_Petro_Tank_Facility_DEV/FeatureServer/0"

fl = FeatureLayer(fl_url, gis)

...other logic...

fl.edit_features(adds=YOUR_ADDS, deletes=YOUR_DELETES, updates=YOUR_UPDATES)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where the adds, deletes, updates are a FeatureSet object, or a list of features in json form (I think you basically have this already with your JSON).&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 01:04:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335651#M9115</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-06T01:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335846#M9119</link>
      <description>&lt;P&gt;WORKED FANTASTIC... thank you very much&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&amp;nbsp;with steering me in the correct direction... and its FAST!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    portal_item = gis.content.get('6e91cfxxxxx1fc7294493dddd')
    ports_layer = portal_item.layers[0]

    for x in os.listdir(path):
        if x.startswith("output"):
            filetoImport = path + x
            f = open(filetoImport)
            data = json.load(f)
            featureAddingAdd = data['features']

            add_result = ports_layer.edit_features(adds = featureAddingAdd)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 17:05:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335846#M9119</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-06T17:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: JSON.Load python file -- Add Features to Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335848#M9120</link>
      <description>&lt;P&gt;Awesome glad to help streamline things!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 17:03:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/json-load-python-file-add-features-to-feature/m-p/1335848#M9120</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-06T17:03:55Z</dc:date>
    </item>
  </channel>
</rss>

