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

Intermittent HTTP 403 issues using DeleteFeaturesFromFeatureLayer #344

Open
fallomj opened this issue Jun 6, 2017 · 3 comments
Open

Intermittent HTTP 403 issues using DeleteFeaturesFromFeatureLayer #344

fallomj opened this issue Jun 6, 2017 · 3 comments

Comments

@fallomj
Copy link

fallomj commented Jun 6, 2017

ArcRestHelper

3/22/17 3.5.x

Issue

I have a script running on a scheduled task that deletes features from a hosted layer and then adds features from file geodatabase.

We have a couple different scripts that use the featureservicetools methods. These scripts are intermittently generating HTTP 403 errors when they attempt to update a feature layer. Access is not an issue because many times the scripts work without issues.

A little context, these scripts run as scheduled tasks every 5-10 minutes and use the same named user account (essentially a service account for these kinds of processes), but they are accessing different data.

Any ideas on what may be causing this?

'function': 'DeleteFeaturesFromFeatureLayer', 'line': 'line 591', 'synerror': 'HTTPError: HTTP Error 403: URLBlocked', 'filename': 'C:\Python27\ArcGIS10.2\lib\site-packages\arcresthelper\featureservicetools.py'

Repo Details

SynchronizeIncidentSvcPts_GISTask.py.txt
Incident Service Points Log 06-06-2017.xml.txt
See attached script and log

@fallomj
Copy link
Author

fallomj commented Jun 13, 2017

Update
I added the dispose() method to make sure the securityhandlerhelper object is properly closed. This change was implemented in our staging environment and has greatly reduced the number of HTTP 403 errors. That said, I did not update our production environment and I'm no longer seeing the issue there.

Is there a maximum number of connections that was being exceeded and causing the URL to be blocked?

@fallomj
Copy link
Author

fallomj commented Jun 14, 2017

Updated script using dispose()

SynchronizeIncidentSvcPts_GISTask.zip

@fallomj
Copy link
Author

fallomj commented Jun 14, 2017

If anyone would like to try this on their own here are the deployment details:

This is run from a scheduled task, the –ini parameter is simply the name of the config file, including the extension, e.g. “Config.ini”.

The script is setup to look for the configuration file in the same directory as the script. If you put it there, the path isn’t needed.

The attached zip has a sample of the .ini file. A note about the AGOL login and password parameters in that file – the script is setup to read encrypted values in this
file. Below is the procedure I use to create these.

  1. Encrypt the username and password
    a. Using python shell, import base64
    b. Encrypt the username and password using
    base64.b64encode(“”)
  2. Add the encrypted login information to your configuration/ini file
  3. Decrypt the username and password at run time by referencing the configuration/ini keys
    a.
    username = base64.b64decode(config.get('SECURITY_SETTINGS', 'Username'))
    b.
    password = base64.b64decode(config.get('SECURITY_SETTINGS', 'Password')

Here are the deployment steps we used

Open and MXD with one layer and save in the location the directory the script will run
2.
Log into ArcGIS Online
3.
Publish as a hosted feature service with the Feature Access capability, turn off Tiled Map capability
4.
Share the hosted service with the appropriate group
5.
Get the service URL for the new hosted layer from ArcGIS Online and update the Config (ini) file in the FeatureService property of SCRIPT_SETTINGS
6.
Copy the folder containing the script to a server
7.
On the server, open the Task Scheduler and create a task that will run this script every 10 minutes reference the screen captures in the attached zip

ConfigFile-TaskSetup.zip

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

1 participant