Hello All,
I have a script that I'm using to download services as a geodatabase using the REST api. It works about half the time -- the other half the time I get a 500 error stemming from a 'No JSON object could be decoded' error. Anyone have any idea why this might be happening? I don't think it's a bug in my script, since it works sometimes, but I've attached it in case anyone has any ideas and wants to see how it's put together. Any feedback is greatly appreciated!
Any chance it is hitting secure services that you don't have proper credentials? Just a guess, I haven't fully deciphered your script.
Nope, it's definitely not a credential problem.
I have the same issue. At 10,000 features it worked great. Not at 32,000 and it dies with the same error as you.
Try:
'expiration': 60,
in your credentials. i.e. an integer, not a string.
It looks like the token is timing out. You have to manage token lifecycle.
This is a whole lot easier in ArcGIS Pro.
Regards
Thanks but where do I put this? No idea where to add that.
Opps thought this was from REST. Here is the code where do I add that?
#Get a local replica of the HFS
proxy_port = None
proxy_url = None
agolSH = AGOLTokenSecurityHandler(username=username,password=password)
fs = FeatureService(url=url,securityHandler=agolSH,proxy_port=proxy_port,proxy_url=proxy_url,initialize=True)
result = fs.createReplica(replicaName='Demo', layers='0,1,2,3', keep_replica=False, layerQueries=None, geometryFilter=None, returnAttachments=True,returnAttachmentDatabyURL=False,returnAsFeatureClass=True, out_path=outDir)
Line 139, in the file downloaded.
As written it was '60', not 60.
You must be looking at the other guys code. Mine is this.
from arcrest.security import AGOLTokenSecurityHandler
from arcrest.agol import FeatureService
from arcrest.common.filters import LayerDefinitionFilter
#Get a local replica of the HFS
proxy_port = None
proxy_url = None
agolSH = AGOLTokenSecurityHandler(username=username,password=password)
fs = FeatureService(url=url,securityHandler=agolSH,proxy_port=proxy_port,proxy_url=proxy_url,initialize=True)
result = fs.createReplica(replicaName='Demo', layers='0,1,2,3', keep_replica=False, layerQueries=None, geometryFilter=None, returnAttachments=True,returnAttachmentDatabyURL=False,returnAsFeatureClass=True, out_path=outDir)
Oops, sorry, yes I was.
I know the arcrest author, I'll bring him in - stand by.
In the meantime, if you run Fiddler while running the script, you may be able to get the request that doesn't return JSON and see what the actual response is. I'd imagine it's html and not JSON, so the WebView response will help in Fiddler, but that's just a guess.