![]() ![]() #for tables ensure the `locationType` is None Print('publishing to Enterprise Portal.') Gis_dest = GIS('portalURL', 'user', 'pass', verify_cert=False, trust_env=True) ![]() Response = requests.get(idph_data,verify=True)į.writerow(, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem]) import json,requestsįull_file = os.path.join(file_path, csv_file) str(datetime.now().strftime('_%m_%d_%Y_%H%M')) '.csv' If I run this I'll get the 'Decoding JSON has failed' error (even in a try/except) and the CSV will neither be added nor published. My only option is to publish as a CSV because in the first part I write requested JSON to a CSV. Print("Layer failed to overwrite, trying again.") HostedFeatureLayerCollection = omitem(hostedFeatureService) Print("Item publishing failed, trying again.")Īnd because this is run on a regular basis the feature layer needs to be overwritten import json,requestsįrom arcgis.features import FeatureLayerCollectionįull_file = os.path.join(file_path, csv_file) '.csv' Pitem = item.publish(publish_parameters=pp) #analyze the CSV file to autogenerate the publish parameters Print("Item failed to add, trying again.") #provide Enterprise Portal login info here #2-this section takes that csv and publishes it to Enterprise Portal. CountyName, AdministeredCount, etc.)į.writerow(, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem, elem]) With open(full_file, 'w', newline='', encoding='UTF-8') as csvfile:į.writerow() #read the json response and keep the VaccineAdministration partĭata = response.json() #1-this section writes the json to a csv-įull_file = os.path.join(file_path, csv_file) '.csv' #the directory you want the csv written toĬsv_file = 'c19_Vaccine_Current_standAloneScriptTest' What we ultimately came up with is a two part script that publishes a CSV to Portal, import json,requests When running a Python script that is set up to add then publish an item to Portal for ArcGIS the POST request to the /addItem endpoint of the Portal is being redirected, which causes the script to crash. After a lot of trouble shooting, I still don't know that we (an ESRI analyst and I) nailed down a cause of that JSONDecode error because we tried so many things. Pitem = item.publish(publish_parameters=pp, for the help. ![]() # For tables ensure the `locationType` is None Modify the publish parameters then publish Gis_dest = GIS('portalurl', 'user', 'pass')įp = r'C:\Users\jpilbeam\Test\c19_Vaccine.csv'Īnalyze_csv = cm.analyze(item=item, file_type='csv') : Expecting value: line 1 column 1 (char 0) But, when I try this in a python IDE the script runs but produces nothing but an error: I'm able to publish a CSV in a Pro Notebook. The only documentation I see for it is for the API. I'm trying use the publish() method in a stand-alone script. I'm the same person who posted about this in the ArcGIS API for Python forum. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |