<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Consume geoprocessing services as a REST service does not show data only structure (schema) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/consume-geoprocessing-services-as-a-rest-service/m-p/1536083#M72794</link>
    <description>&lt;P&gt;Good afternoon&lt;/P&gt;&lt;P&gt;When I run this GPService directly in my browser&amp;nbsp; I get as a result&amp;nbsp; a json file with the structure (Schema)&amp;nbsp; &amp;nbsp;and the data.&amp;nbsp; The service returns a feature polygon.&lt;/P&gt;&lt;P&gt;When I run this same GpService in Python as a REST service, I only get the structure or schema, not the data.&lt;/P&gt;&lt;P&gt;The code is pasted below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Requires Python 3+&lt;BR /&gt;import requests&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Define the parameters for the geoprocessing task (here, a simple string-based task)&lt;BR /&gt;params = {&lt;BR /&gt;'ID': "98212", # Input ID as a string&lt;BR /&gt;&lt;BR /&gt;'f': 'json' # Response format&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;URL = '&lt;A href="https://myserver/arcgis/rest/services/myfolder/myGpServer/GPServer/MyTask" target="_blank"&gt;https://myserver/arcgis/rest/services/myfolder/myGpServer/GPServer/MyTask&lt;/A&gt;&lt;/P&gt;&lt;P&gt;# Send the request to the geoprocessing service&lt;BR /&gt;response = requests.post(URL, data=params)&lt;/P&gt;&lt;P&gt;# Check if the request was successful&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;# Parse the response JSON&lt;BR /&gt;result = response.json()&lt;BR /&gt;print("Geoprocessing result:", json.dumps(result, indent=4))&lt;/P&gt;&lt;P&gt;# Extract the buffer geometry from the response (if available)&lt;BR /&gt;if 'geometries' in result:&lt;BR /&gt;buffer_geometry = result['geometries'][0]&lt;BR /&gt;print("\nExtracted Buffer Geometry:")&lt;BR /&gt;print(json.dumps(buffer_geometry, indent=4))&lt;BR /&gt;else:&lt;BR /&gt;print(f"Error: {response.status_code} - {response.text}")&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2024 20:33:07 GMT</pubDate>
    <dc:creator>SanchezNuñez</dc:creator>
    <dc:date>2024-09-06T20:33:07Z</dc:date>
    <item>
      <title>Consume geoprocessing services as a REST service does not show data only structure (schema)</title>
      <link>https://community.esri.com/t5/python-questions/consume-geoprocessing-services-as-a-rest-service/m-p/1536083#M72794</link>
      <description>&lt;P&gt;Good afternoon&lt;/P&gt;&lt;P&gt;When I run this GPService directly in my browser&amp;nbsp; I get as a result&amp;nbsp; a json file with the structure (Schema)&amp;nbsp; &amp;nbsp;and the data.&amp;nbsp; The service returns a feature polygon.&lt;/P&gt;&lt;P&gt;When I run this same GpService in Python as a REST service, I only get the structure or schema, not the data.&lt;/P&gt;&lt;P&gt;The code is pasted below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Requires Python 3+&lt;BR /&gt;import requests&lt;BR /&gt;import json&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Define the parameters for the geoprocessing task (here, a simple string-based task)&lt;BR /&gt;params = {&lt;BR /&gt;'ID': "98212", # Input ID as a string&lt;BR /&gt;&lt;BR /&gt;'f': 'json' # Response format&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;URL = '&lt;A href="https://myserver/arcgis/rest/services/myfolder/myGpServer/GPServer/MyTask" target="_blank"&gt;https://myserver/arcgis/rest/services/myfolder/myGpServer/GPServer/MyTask&lt;/A&gt;&lt;/P&gt;&lt;P&gt;# Send the request to the geoprocessing service&lt;BR /&gt;response = requests.post(URL, data=params)&lt;/P&gt;&lt;P&gt;# Check if the request was successful&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;# Parse the response JSON&lt;BR /&gt;result = response.json()&lt;BR /&gt;print("Geoprocessing result:", json.dumps(result, indent=4))&lt;/P&gt;&lt;P&gt;# Extract the buffer geometry from the response (if available)&lt;BR /&gt;if 'geometries' in result:&lt;BR /&gt;buffer_geometry = result['geometries'][0]&lt;BR /&gt;print("\nExtracted Buffer Geometry:")&lt;BR /&gt;print(json.dumps(buffer_geometry, indent=4))&lt;BR /&gt;else:&lt;BR /&gt;print(f"Error: {response.status_code} - {response.text}")&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 20:33:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/consume-geoprocessing-services-as-a-rest-service/m-p/1536083#M72794</guid>
      <dc:creator>SanchezNuñez</dc:creator>
      <dc:date>2024-09-06T20:33:07Z</dc:date>
    </item>
  </channel>
</rss>

