REST API - No JSON Object could be decoded

6188
10
05-22-2015 03:05 AM
TrilliumLevine1
Occasional Contributor

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!

Tags (2)
0 Kudos
10 Replies
RebeccaStrauch__GISP
MVP Emeritus

Any chance it is hitting secure services that you don't have proper credentials?  Just a guess, I haven't fully deciphered your script.

0 Kudos
TrilliumLevine1
Occasional Contributor

Nope, it's definitely not a credential problem.

0 Kudos
DougBrowning
MVP Esteemed Contributor

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.

0 Kudos
BruceHarold
Esri Regular Contributor

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

0 Kudos
DougBrowning
MVP Esteemed Contributor

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)

0 Kudos
BruceHarold
Esri Regular Contributor

Line 139, in the file downloaded.

As written it was '60', not 60.

0 Kudos
DougBrowning
MVP Esteemed Contributor

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)

0 Kudos
BruceHarold
Esri Regular Contributor

Oops, sorry, yes I was.

I know the arcrest author, I'll bring him in - stand by.

0 Kudos
JonathanQuinn
Esri Notable Contributor

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.

0 Kudos