Authentification problem when using Urban API

245
1
Jump to solution
08-30-2021 06:38 AM
MaximeDemers
Occasional Contributor III

Hi,

I am trying to use the Urban API but I got authentification error:

GraphQL query failed with 1 errors
[{'message': 'The access token provided is invalid or expired.', 'extensions': {'code': 'UNAUTHENTICATED'}}]


Im not sure why the token provided to the urban api url is not working because it was generated using arcpy like below:

import arcpy
from sgqlc.operation import Operation
from sgqlc.endpoint.http import HTTPEndpoint
from urban_api_schema import urban_api_schema as schema

arcpy.SignInToPortal("https://www.arcgis.com", "myUserName", "MyPasswOrd")
#token is generated correctly
token = arcpy.GetSigninToken()
urban_api_url = "https://urban-api.arcgis.com/graphql" + '?token=' + token['token']

endpoint = HTTPEndpoint(urban_api_url)

#here it's the function that call the api to update the parcels
for parcel_chunk in parcels_chunks:
  op = Operation(schema.Mutation)
  create_parcels = op.create_parcels(urban_database_id="1c80e3e815594fd288d347e132138f0a", parcels=parcel_chunk)
  create_parcels.attributes.__fields__('global_id')

  json_data = endpoint(op)
    errors = json_data.get('errors')
  if errors:
    print(errors)
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Till_Schmid
Esri Contributor

Thanks for this question, @MaximeDemers 

This is a question regarding the Urban API and seems to be a duplicate of https://community.esri.com/t5/arcgis-urban-api-questions/authentification-problem-using-arcpy/m-p/10.... Please follow the thread there. Thanks!

View solution in original post

0 Kudos
1 Reply
Till_Schmid
Esri Contributor

Thanks for this question, @MaximeDemers 

This is a question regarding the Urban API and seems to be a duplicate of https://community.esri.com/t5/arcgis-urban-api-questions/authentification-problem-using-arcpy/m-p/10.... Please follow the thread there. Thanks!

View solution in original post

0 Kudos