I've published a simple geoprocessing service that takes an uploaded zip file and unzips it. The geoprocessing service was published with "uploads" enabled. I have also enabled "Info" level messaging, but nothing gets logged so that's been useless. When I run the GP service in ArcMap, it runs perfectly fine and does what I expect it to do. When I try running from the rest API, I get a failure message. When I try running from the JavaScript API, I get a failure message also that's a little more detailed, it says I have an Invalid URL but I'm not sure what URL it's evaluating...

Rest API input (I'm not entirely sure I'm inputting it right so it could be that): enter image description here

After clicking "Submit Job (POST)", I get this: enter image description here

In the JavaScript API, this is my code:

) {

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

var featureLayer = new FeatureLayer("https://www.myurl.org/xxx/rest/services/HbMonitoringTest/HabitatData/MapServer/1");


gp = new Geoprocessor("https://www.myurl.org/xx/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)
  var upload = esri.request({  
    url: "https://www.myurl.org/xxx/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+ "}" };
  gp.submitJob(params, gpJobComplete, gpJobStatus, function(error){
    console.log(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);


For the error I get a HTTP 400 error, "Invalid URL": enter image description here

  • 1
    At the REST API (services endpoint), you can't put the path in like that, try this: {'url':'https://www.myurl.org/myfile.zip'}
    – KHibma
    Mar 27, 2018 at 13:46
  • @KHibma - Thank you, that's really helpful to know for the future! I actually found my stupid mistake in the javascript code, my geprocessor doesn't include the tool name at the end of the URL. Got everything working now :)
    – MKF
    Mar 27, 2018 at 13:59

1 Answer 1


I figured out why my javascript wasn't working. The geoprocessor I set up doesn't include the tool name at the end of the URL, which is why it was invalid. Here's what that line should be:

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

To run from Rest API, I first had to go through the "Upload" task to create an item ID: enter image description here enter image description here

Next, I had to go to the task and submit a job with the URL generated with that item ID: enter image description here

This resulted in success!

  • 1
    Actually, after you've uploaded it to the uploads end point, you could do it by reference like: {'itemID': "longitemid"}
    – KHibma
    Mar 27, 2018 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.