POST
|
I need a Python script that uses ArcGIS REST API to upload a zip file and update a hosted feature service -- NOT using the arcgis package. I trying to follow Update. Here's what I have so far -- but nothing is successfully posting or updating. import requests import json import os from datetime import datetime now = datetime.now() # dd/mm/YY H:M:S dt_string = now.strftime("%m/%d/%Y") # ArcGIS REST API URL for the item to be updated item_id = "itemid" url = f"https://myorg.maps.arcgis.com/sharing/rest/content/items/{item_id}/update" # Get token baseURL = "https://www.arcgis.com" loginURL = "https://www.arcgis.com/sharing/rest/generateToken".format(baseURL) username = "username" password = "password" expiration = 60 loginparams = {'username': username, 'password': password, 'client': 'referer', 'referer': baseURL, 'expiration': expiration, 'f': 'json'} loginresponse = requests.post(loginURL, data=loginparams, verify=False) token = loginresponse.json()['token'] # Path to the updated zipped shapefile updated_shapefile_path = "C:\\GIS\\myzip.zip" # Prepare the request headers headers = { "Content-Type": "multipart/form-data", } # Prepare the request parameters params = { "f": "json", "title": f"My layer {dt_string}", "description": f"My description - Last downloaded {dt_string}", "snippet": f"My snippet - Last updated {dt_string}", "token": token } # Open the shapefile in binary mode with open(updated_shapefile_path, "rb") as file: files = {"file": (os.path.basename(updated_shapefile_path), file)} try: response = requests.post(url, params=params, headers=headers, files=files) response.raise_for_status() if response.status_code == 200: print("Shapefile updated successfully.") else: print(f"Failed to update shapefile. Status code: {response.status_code}") print(response.text) except requests.exceptions.RequestException as e: print(f"Error during shapefile update: {e}") # Check the response if response.status_code == 200: print("Shapefile updated successfully.") else: print(f"Failed to update shapefile. Status code: {response.status_code}") print(response.text)
... View more
01-22-2024
08:58 PM
|
0
|
1
|
306
|
BLOG
|
Disregard my previous message. I figured out what I was doing wrong!
... View more
12-04-2023
04:54 PM
|
1
|
0
|
339
|
POST
|
I submitted a case with Esri about using FTP with AGOL Notebooks, and got this back today -- ------------------------------------------------------------------------------------------------------------ Case #03441759 The behavior you've described, where FTP connections appear to be blocked when running a script in ArcGIS Online Notebooks, is likely a result of the security and network access restrictions enforced within the ArcGIS Online environment. ArcGIS Online is hosted in a secure cloud-based platform, and these measures are in place to ensure the security of the platform and its users. If you're encountering a "ConnectionRefusedError: [Errno 111] Connection refused" error, this is indicative of the FTP connection not being allowed. To work around this limitation, I recommend using an alternative approach: consider utilizing another server where the ArcGIS API for Python can be employed to upload data to ArcGIS Online. Unfortunately, AGOL Notebooks cannot use FTP to download data due to these security restrictions. ------------------------------------------------------------------------------------------------------------ So yeah -- FTP connections are blocked with AGOL and AGOL Notebooks.
... View more
09-19-2023
01:23 PM
|
0
|
0
|
219
|
POST
|
I submitted a case with Esri and got this back -- ------------------------------------------------------------------------------------------------------------ Case #03441759 The behavior you've described, where FTP connections appear to be blocked when running a script in ArcGIS Online Notebooks, is likely a result of the security and network access restrictions enforced within the ArcGIS Online environment. ArcGIS Online is hosted in a secure cloud-based platform, and these measures are in place to ensure the security of the platform and its users. If you're encountering a "ConnectionRefusedError: [Errno 111] Connection refused" error, this is indicative of the FTP connection not being allowed. To work around this limitation, I recommend using an alternative approach: consider utilizing another server where the ArcGIS API for Python can be employed to upload data to ArcGIS Online. Unfortunately, AGOL Notebooks cannot use FTP to download data due to these security restrictions. ------------------------------------------------------------------------------------------------------------ So yeah -- FTP connections are blocked with AGOL and AGOL Notebooks. So don't bother going down this path.
... View more
09-19-2023
01:22 PM
|
1
|
0
|
550
|
POST
|
While trying to port a stand-alone Python script to an ArcGIS Online Notebook, I am noticing the same thing. Through ftplib and wget -- all attempts getting same "Connection refused" error.
... View more
09-14-2023
06:38 PM
|
0
|
0
|
295
|
POST
|
Thanks, that looks promising. I will get it a shot and let you know how it goes.
... View more
09-14-2023
02:01 PM
|
0
|
0
|
566
|
POST
|
Thanks -- yep, I think that is the problem. Made all kinds of changes to manifest.json and strings.js to force that they are 2 different widgets -- and no luck. Same response -- first one you open will work and continue to work, but second one fails. How exactly is the widgetId set? I see names and other other properties for widgets in the code, but not the widgetId? Do you know how that is set?
... View more
08-13-2019
03:59 PM
|
0
|
0
|
1028
|
POST
|
And continuing trying to open/close the duplicated widgets -- undefined init.js:586 Uncaught TypeError: Cannot read property '_getInfo' of undefined at Object._getFrameWidth (init.js:586) at Object._setClipRect (init.js:628) at Object.onResize (init.js:606) at Object.advice (init.js:120) at Object.c [as onResize] (init.js:120) at Object._resize (init.js:627) at Object._execResize (init.js:625) at Object._execResize (init.js:64) at Object._timedResize (init.js:625) at init.js:64 ObliqueViewer.js:32 Oblique viewer: records not provided. setData @ ObliqueViewer.js:32 (anonymous) @ ObliqueViewer.js:26 l @ init.js:108 k @ init.js:108 resolve @ init.js:110 (anonymous) @ ObliqueViewer.js:27 c @ init.js:104 e @ init.js:104 resolve.callback @ init.js:106 _resDfd @ init.js:682 _successHandler @ init.js:2303 _handler @ init.js:2297 (anonymous) @ init.js:64 (anonymous) @ init.js:2292 c @ init.js:104 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:2301 (anonymous) @ init.js:2301 c @ init.js:104 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 (anonymous) @ init.js:1050 c @ init.js:104 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 c @ init.js:105 e @ init.js:104 resolve.callback @ init.js:106 (anonymous) @ init.js:93 l @ init.js:108 k @ init.js:108 resolve @ init.js:110 a @ init.js:109 l @ init.js:108 k @ init.js:108 resolve @ init.js:110 a @ init.js:109 l @ init.js:108 k @ init.js:108 resolve @ init.js:110 a @ init.js:109 l @ init.js:108 k @ init.js:108 resolve @ init.js:110 d @ init.js:140 f @ init.js:144 load (async) r @ init.js:145 l @ init.js:141 b.xhr @ init.js:93 b.xhrGet @ init.js:93 B @ init.js:1046 f @ init.js:1048 I @ init.js:1056 (anonymous) @ init.js:1056 c @ init.js:104 B.then.then @ init.js:106 always @ init.js:113 F @ init.js:1056 execute @ init.js:2291 (anonymous) @ init.js:1234 c @ init.js:104 B.then.then @ init.js:106 addCallbacks @ init.js:106 c.<computed> @ init.js:1234 search @ ObliqueViewer.js:27 locate @ ObliqueViewer.js:26 onOpen @ Widget.js?wab_dv=2.11:114 openWidget @ WidgetManager.js?wab_dv=2.11:547 (anonymous) @ BaseWidgetPanel.js?wab_dv=2.11:164 forEach @ init.js:71 onOpen @ BaseWidgetPanel.js?wab_dv=2.11:162 d @ init.js:198 onOpen @ OnScreenWidgetPanel.js?wab_dv=2.11:239 (anonymous) @ PanelManager.js?wab_dv=2.11:169 (anonymous) @ init.js:64 l @ init.js:108 then.b.then @ init.js:111 openPanel @ PanelManager.js?wab_dv=2.11:167 showPanel @ PanelManager.js?wab_dv=2.11:57 switchToOpen @ OnScreenWidgetIcon.js?wab_dv=2.11:153 onClick @ OnScreenWidgetIcon.js?wab_dv=2.11:85 (anonymous) @ OnScreenWidgetIcon.js?wab_dv=2.11:50 (anonymous) @ init.js:64 Show 72 more frames
... View more
08-12-2019
08:57 AM
|
0
|
2
|
1028
|
POST
|
When I first use one of the 2 ObliqueViewers -- there are no errors. But then close 1 and open the other - and yes there are errors -- WidgetManager.js?wab_dv=2.11:519 fail to close widget ObliqueViewer. TypeError: Cannot read property 'clear' of null at Object._clearAll (https://laptop:3344/webappbuilder/apps/4/widgets/ObliqueViewer/Widget.js?wab_dv=2.11:382:29) at Object.onClose (https://laptop:3344/webappbuilder/apps/4/widgets/ObliqueViewer/Widget.js?wab_dv=2.11:472:14) at Object.closeWidget (https://laptop:3344/webappbuilder/apps/4/jimu.js/WidgetManager.js?wab_dv=2.11:517:18) at Object.<anonymous> (https://laptop:3344/webappbuilder/apps/4/jimu.js/BaseWidgetPanel.js?wab_dv=2.11:172:30) at Object.forEach (https://js.arcgis.com/3.27/init.js:71:486) at Object.onClose (https://laptop:3344/webappbuilder/apps/4/jimu.js/BaseWidgetPanel.js?wab_dv=2.11:170:13) at Object.advice (https://js.arcgis.com/3.27/init.js:120:313) at Object.c [as onClose] (https://js.arcgis.com/3.27/init.js:120:103) at Object.<anonymous> (https://laptop:3344/webappbuilder/apps/4/jimu.js/PanelManager.js?wab_dv=2.11:198:15) at https://js.arcgis.com/3.27/init.js:64:337
... View more
08-12-2019
08:54 AM
|
0
|
3
|
1028
|
POST
|
Using Launchpad Theme. Each widget effectively opens/closes -- but do not function correctly. Open the 2018 widget, and it works with it's respective layer -- but then close it and open the 2019 widget, and that one just doesn't work -- displaying no data or errors. Close and re-launch the app -- open 2019 widget first, and it displays those images just fine, then open the 2018 widget, and it no longer displays those images.
... View more
08-09-2019
03:45 PM
|
0
|
5
|
1028
|
POST
|
I need to configure 2 instances of the Oblique Viewer with our custom Web AppBuilder app -- 1 to display images from one year/service, and the other to hit another year/service. I have successfully cloned the ObliqueViewer widget -- copying the sourcecode, making a few changes to instantiate as different widgets (ie ObliqueViewer and ObliqueViewer2), but no luck. You can only effectively use one or the other. Somewhere there must be a parameter that is conflicting between the 2. Anybody ever had any luck trying to do such?
... View more
08-09-2019
03:18 PM
|
0
|
9
|
1250
|
POST
|
The widget is here -- https://github.com/Esri/oriented-imagery
... View more
07-29-2019
12:03 PM
|
2
|
0
|
1125
|
POST
|
The GIC activated to Level 3 – Enhanced Monitoring on 10-Jul-2019 for Potential Tropical Cyclone 2 which would eventually become Hurricane Barry. On 15-July GIC stood-down and returned to Level 4 – Monitoring. Following 5 days of monitoring for damage assessments, soliciting input from GIC insurer members, and coordinating with FEMA, NOAA, and other federal and state emergency management, this storm has not triggered thresholds established in the GIC Gray Sky Playbook for activation for imagery collection. The playbook calls for activation for imagery collection for hurricanes of Category 2 and greater or in special circumstances for Category 1. Given low damage and utility for our insurer members, GIC did not collect imagery for Barry. Thanks, Richard Butgereit Director of Catastrophe Response Geospatial Intelligence Center <mailto:richard.butgereit@geointel.org> richard.butgereit@geointel.org 850-591-2694
... View more
07-17-2019
06:14 AM
|
1
|
0
|
653
|
POST
|
This also returns a blank page -- http:// myserver.com/proxy/proxy.ashx?http://xxxxxx.maps.arcgis.com/apps/webappviewer/index.html?id=xxxxxxxxxxxxxxxxxxxx I had shortened the URL. Let me re-state the desired scenario -- as maybe I have a misunderstanding... I want users to login in to our .NET ASP application. They will use that application to perform searches, display results, and then click links to open a secured web app (which may be hosted in our AGO or deployed on the same server hosting the .NET ASP) with a secured map service without being challenged again to authenticate to AGO. What am I missing?
... View more
12-04-2017
11:13 PM
|
0
|
1
|
457
|
Title | Kudos | Posted |
---|---|---|
1 | 09-19-2023 01:22 PM | |
1 | 12-04-2023 04:54 PM | |
1 | 03-04-2016 07:34 AM | |
2 | 07-29-2019 12:03 PM | |
1 | 07-17-2019 06:14 AM |
Online Status |
Offline
|
Date Last Visited |
yesterday
|