Select to view content in your preferred language

Consume geoprocessing services as a REST service does not show data only structure (schema)

87
0
Friday
SanchezNuñez
Occasional Contributor II

Good afternoon

When I run this GPService directly in my browser  I get as a result  a json file with the structure (Schema)   and the data.  The service returns a feature polygon.

When I run this same GpService in Python as a REST service, I only get the structure or schema, not the data.

The code is pasted below:

 

# Requires Python 3+
import requests
import json


# Define the parameters for the geoprocessing task (here, a simple string-based task)
params = {
'ID': "98212", # Input ID as a string

'f': 'json' # Response format
}

 

URL = 'https://myserver/arcgis/rest/services/myfolder/myGpServer/GPServer/MyTask

# Send the request to the geoprocessing service
response = requests.post(URL, data=params)

# Check if the request was successful
if response.status_code == 200:
# Parse the response JSON
result = response.json()
print("Geoprocessing result:", json.dumps(result, indent=4))

# Extract the buffer geometry from the response (if available)
if 'geometries' in result:
buffer_geometry = result['geometries'][0]
print("\nExtracted Buffer Geometry:")
print(json.dumps(buffer_geometry, indent=4))
else:
print(f"Error: {response.status_code} - {response.text}")

0 Kudos
0 Replies