AnsweredAssumed Answered

Adding a shapefile to a feature layer using arcgis js api

Question asked by Nalydleetlub on May 3, 2017
Latest reply on May 4, 2017 by Nalydleetlub

I have the following code and up until a couple of weeks ago (or possibly one or two months because I hadn't used it in some time) everything seemed to be working fine:

function generateFeatureCollection(fileName) {    require(["esri/geometry/scaleUtils", "esri/request", "dojo/dom", "dojo/on", "dojo/_base/lang"], function (scaleUtils, request, dom, on, lang) {        var portalUrl = "";"progress"); = 'progress';        //resolving the fakepath issue in the file location url        var name = fileName.split(".");        name = name[0].replace("c:\\fakepath\\", "");         var params = {            'name': name,            'targetSR':,            'maxRecordCount': 12500,            'enforceInputFileSizeLimit': true,            'enforceOutputJsonSizeLimit': true        };         var extent = scaleUtils.getExtentForScale(, 40000);        var resolution = extent.getWidth() /;        params.generalize = true;        params.maxAllowableOffset = resolution;        params.reducePrecision = true;        params.numberOfDigitsAfterDecimal = 0;         var myContent = {            'filetype': 'shapefile',            'publishParameters': JSON.stringify(params),            'f': 'json',            'callback.html': 'textarea'        };         var genRequest = request({            url: portalUrl + '/sharing/rest/content/features/generate',            content: myContent,            form: dom.byId('uploadForm'),            handleAs: 'json',            load: lang.hitch(this, function (response) {                if (response.error) {                    return;                }                addShapefileToMap(response.featureCollection);            }),        });        genRequest.then(            function (response) {                //console.log("Success: ", response.layers);            }, function (error) {                app.notifyError("Error on upload.");                $('#IEFill').append("<b>Upload Error: "+error+"</b>");            });    });}

However recently an error is being thrown in the last part of the code where the line is:

app.notifyError("Error on upload.");

The following error is being thrown and I have been through all my code and have no idea what I may be doing wrong especially since this process was working and no changes were made to the best of my knowledge.

SyntaxError: Unexpected token <at Object.b.fromJson (init.js:230)at Object.json (init.js:187)at s (init.js:192)at c (init.js:76)at d (init.js:76)at b.Deferred.resolve.callback (init.js:77)at init.js:195at k (init.js:199)at m (init.js:199)at f.resolve (init.js:201)

Would anyone know why this error is being thrown and any possible solutions for it?