GPServer Task failing with no error

919
3
12-19-2017 09:29 AM
DevonCanady
New Contributor II

I have created a geoprocessing task on ArcServer 10.1 from a Python Script Tool's execution found in Geoprocessing>>Results Window>>Share As>>Geoprocessing Service. The tool takes two inputs, a JOBID (GUID) and a file path as the output location - both strings. After configuring the service I can access it via the ArcGIS REST Services Directory, if I go to [TASKNAME]>>Submit Job it takes me to a web form where I can provide the input and execute the task.

I'm actually going to just be using the URL of this page to provide the input via URL query string parameters in the long run, but either way the execution of the task from the web will result in the Job Messages:

esriJobMessageTypeInformative: Submitted.

esriJobMessageTypeInformative: Executing...

esriJobMessageTypeError: Failed

The tool executed successfully when run from the Script Tool's form locally, but when running the same exact tool/parameters from the web service it fails and I'm not getting a descriptive error. My suspicion is that the file path may not fit the URL encoding standard but I'm not sure how to fix that or if I should send a file path as input like this.

0 Kudos
3 Replies
JamesCrandall
MVP Frequent Contributor

Setup a request and process the response using json, urlib

import json
import urllib, urllib2, urlparse

qURL = "https://somedomain.com/rest/services/GPServicename/GPServer/GPTaskName/execute"
params = urllib.urlencode({'f': 'json',
                           'inputGUID': <some value>, 
                           'inputFilePath': <some value>, 
                           'returnZ': 'false', 'returnM': 'false'})

req = urllib2.Request(qURL, params)
response = urllib2.urlopen(req)
jsonResult = json.load(response)

print jsonResult

#parse the result as necessary‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
JonathanQuinn
Esri Notable Contributor

Why is an input to the tool a jobID? When you run a GP service, a jobID folder is created for you and Server knows to put any temporary or output data into that folder. That also serves as the output location, so your input path won't be honored. The two parameters you've set up for the task aren't correct, so that may be the cause of the failure.  You can increase the message level for your service through the service properties in Manager or ArcMap/ArcCatalog, but I expect you'll get an error indicating a path can't be found or something of that nature.

What does the rest of the script do?

0 Kudos
DevonCanady
New Contributor II

The jobID input is in reference to a different jobID than the one created for the GP Task, essentially it is used to parse a JSON geometry from a web page on our site so the script can run buffer analyses. The jobID is appended to a URL which the script uses to send another HTTP GET to retrieve a web page in JSON, which contains the JSON geometry needed as input. The JSON web page also contains other input the script needs and it saves the user some work since it already exists on our site anyways.

The ultimate result of this script is a SQL query, it's essentially just writing out a text file that the user will then need to QC and use SSMS to actually run the queries against the database. The step of double checking the programatically written SQL code is important. Since no result actually needs to be returned to the client and I'm just writing the file to the specified path, how might I get the script to write to the default output for the GP Task instead of the file path input?

0 Kudos