esri javscript geoprocessor

469
0
03-13-2018 08:07 AM
DanielWebb2
New Contributor III

I am trying to get the Geoprocessor to work in the Javascript 4.6 API.  Here is my code.

var fs = new FeatureSet({

    "fields": [{
        "name": "STREET",
        "type": "esriFieldTypeString",
        "alias": "STREET"
     }],
     "features": [{
         "attributes": {
             "STREET": "E 1ST AVE"
        }
     }]
});
var params = {
     "JsonInputs": fs
};
var gp = new Geoprocessor({
    url: gpUrl
});
gp.submitJob(params).then(gpCallback, gpErrback);

This returns an error that says;

TypeError: a.toJSON is not a function
       at dojo.js:1455
       at Object.forEach (dojo.js:97)
       at Object.h._encodeGraphics (dojo.js:1455)
       at Object.toJSON (dojo.js:1439)
       at Object._encode (dojo.js:1435)
       at Object._gpEncode (Geoprocessor.js:12)
       at Object.<anonymous> (Geoprocessor.js:10)
       at g (dojo.js:132)
       at a.extend.then.then.c.then (dojo.js:135)
       at Object.submitJob (Geoprocessor.js:10)

When I post the json directly in the rest service it completes successfully.  So the problem must be how my javascript is set up.  Any insights would be helpful.

Thank you!

-----------------------------

Update: I rolled the API back to 3.23 and it works.  So is this a bug in 4.6, maybe?

Also attaching a screenshot of the rest service parameters, just in case that is helpful.

Update April 10, 2018:

The error at dojo.js: 1455 is for a function that looks like this:

h._encodeGraphics = function(a, e) {
   var g = [];
   n.forEach(a, function(a, b) {
      a = a.toJSON();
      var c = {};
      if (a.geometry) {
         var k = e && e;
         c.geometry = k && k.toJSON() || a.geometry
      }
      a.attributes && (c.attributes = a.attributes);
      g = c
   });
   return g
}

Is this because the FeatureSet "features" is a Graphic[]? (https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#fea...)

What I am trying to do is update a table, so perhaps this is throwing something off because it wants graphics?  But like I said, it works if I use 3.23 API.  So what is different with 4.6?

0 Kudos
0 Replies