Select to view content in your preferred language

'error': {'code': 498, 'message': 'Invalid Token'

26618
15
Jump to solution
12-07-2020 03:34 AM
Clive_S
Emerging Contributor

I used the ESRI Python token code sample, which returns a token.

However when I use the token in <url+token>, I get an error??

formatted_json = [feature['attributes'] for feature in raw_json['features']]
KeyError: 'features'
{'error': {'code': 498, 'message': 'Invalid Token', 'details': []}}

 

The code is:

ef get_token():
    params = {'username': username, 'password': password, 'expiration': str(60), 'client': 'referer', 'referer': referer, 'grant_type': 'client_credentials', 'client_id': client_id, 'client_secret': client_secret,   'f': 'json'}
    request = requests.get(token_url, params=params)
    response = request.json()
    #print(response)
    token = response['access_token']
    return token

portalToken = get_token()
#### THIS works + returns Token
#print(portalToken)
##print("END")

if __name__ == "__get_token__":
    """optional location for parameters"""
    print(sys.argv[0])

 The get_token returns a token.. they all seem to have .. at the end of the token?? This is really frustrating, would appreciate any pointers!!

Thanks,

Clive

 

Tags (3)
0 Kudos
15 Replies
Clive_S
Emerging Contributor

Hi David,

Thanks that header (

headers = {'content-type': 'application/x-www-form-urlencoded'}) Solved the problem.

 

Much appreciated 

0 Kudos
Joel_Lopez
Occasional Contributor

Hi David, I am getting a similar error in a standalone ArcGIS Server 10.5.1. I am trying to view a map services' item information (url = ServerURL/admin/services/ServiceName.MapServer/iteminfo/manifest/manifest.json).
I am able to generate the token but when I get the error as a response. 
Any ideas on how to resolve or troubleshoot? This error does not occur in ArcGIS Enterprise 10.8.1

jxl090120_0-1676494551672.png

 

0 Kudos
DavidPike
MVP Notable Contributor

Hi, maybe best to create a new post to get more traction.  I don't really understand why you're passing a token when you have the GIS object, or why you are using a mix of the Python API and REST API, is there a sample you're working from?
I can dig out a python API script to extract manifest details if you like?  What do you need to achieve exactly?

0 Kudos
Joel_Lopez
Occasional Contributor

Hey David, at the time I didn't realize I could get to the manifest properties from the service object 😑 (i.e service.iteminformation.manifest). Doing so revolved my issue. 

0 Kudos
haoechibubao
New Contributor

Hi jxl090120,

Have you resolved this error? I am having the same problem! I also want to request content of manifest json. I would appreciate with any suggestions!

 

Lin

0 Kudos
Joel_Lopez
Occasional Contributor

Hi Lin, I ended up just getting to the manifest info through the service object.
services = gis_server.services.list()
for service in services:
   man = service.iteminformation.manifest
   print(man)

 

 

0 Kudos