Invalid URL Error for Geoprocessing Service

1425
2
Jump to solution
03-27-2018 06:39 AM
MollyFoley
Regular Contributor

I'm having a really hard time with this and I hope someone can shed some light. I've published a geoprocessing service that accepts uploads, I've also enabled "info" level messages. Unfortunately, nothing ever gets logged in server manager when this error occurs, so the messaging is kind of useless at this point. When I run the GP Service from ArcMap it works perfectly. When I run it from the rest API, I get a plain "failure" message. When I run it from my Javascript API, I get this error message:

I don't even know where to start debugging this. I don't know what URL it's looking evaluating as bad. I've never done a file upload via the Javascript API before so it could be something in the code that's wrong, but in the console it successfully uploads the zip file and creates an item ID, so it's uploading fine, I just can't seem to pass it to my GP service correctly. 

This is my javascript code:

require([
    "esri/map",
    "esri/request",
    "esri/arcgis/utils",
    "esri/layers/FeatureLayer",
    "esri/tasks/Geoprocessor",
    "dojo/dom",
    "dojo/on",
    "dojo/domReady!"
  ],
  function(
    Map,
    esriRequest,
    arcgisUtils,
    FeatureLayer,
    Geoprocessor,
    dom,
    on
  ) {

    var map = new Map("map", {
      basemap: "hybrid",
      center: [-77.069, 36.950],
      zoom: 14
    });

    var featureLayer = new FeatureLayer("https://URL/servername/rest/services/HbMonitoringTest/HabitatData/MapServer/1");

    map.addLayer(featureLayer);

    gp = new Geoprocessor("https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer");

    on(dom.byId("upload"), "click", upload);
    function upload(){
      //upload the zip file and get back the itemID (via uploadSucceeded)  
      console.log("Inside upload function now");
      var upload = esri.request({  
        url: "https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer/uploads/upload", 
        form: dojo.byId("uploadForm"),  
        content: {f: 'json'},  
        handleAs: 'json',
      }).then(uploadSucceeded, uploadFailed);  
    }
    
    function uploadSucceeded(response) {  
      var itemID = response["item"].itemID;  
      console.log("File upload successful, item ID: ", itemID);
      var params = {"Input_Zip_File": "{'itemID':" +itemID+ "}" };
      console.log('Input parameters: '+ dojo.toJson(params));
      console.log("submitting job");
      gp.submitJob(params, gpJobComplete, gpJobStatus, function(error){
        console.error(error.jobStatus + '(' + error.jobId + '):' + dojo.toJson(error));
      });
    }
    
    function gpJobComplete(result){
      console.log(result.jobStatus + '(' + result.jobId + ')')
    }
    
    function gpJobStatus(result){
      console.log(result.jobStatus + '(' + result.jobId + '):' + dojo.toJson(message));
    }
      
    function uploadFailed(response){
      console.log("Failed: ", response);
    }

  });

I've tried running it in the rest API, it successfully creates a job, but the process fails.

Input page:

After clicking "Submit Job (POST)":

1 Solution

Accepted Solutions
MollyFoley
Regular Contributor

I swear, immediately after I post a question I always figure out the mistake I made. My geoprocessing service URL was missing the actual tool name at the end of it. Should be this:

gp = new Geoprocessor("https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer/ZipTest");

View solution in original post

2 Replies
MollyFoley
Regular Contributor

I swear, immediately after I post a question I always figure out the mistake I made. My geoprocessing service URL was missing the actual tool name at the end of it. Should be this:

gp = new Geoprocessor("https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer/ZipTest");
SigamGeo
New Contributor II

Thanks, I had exactly the same problem, my first time using geoprocessor and documentation does not make clear that you need add the tool name to the url.

0 Kudos