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:
However recently an error is being thrown in the last part of the code where the line is:
function generateFeatureCollection(fileName) { require(["esri/geometry/scaleUtils", "esri/request", "dojo/dom", "dojo/on", "dojo/_base/lang"], function (scaleUtils, request, dom, on, lang) { var portalUrl = "http://www.arcgis.com"; app.map.setMapCursor("progress"); document.body.style.cursor = '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': app.map.spatialReference, 'maxRecordCount': 12500, 'enforceInputFileSizeLimit': true, 'enforceOutputJsonSizeLimit': true }; var extent = scaleUtils.getExtentForScale(app.map, 40000); var resolution = extent.getWidth() / app.map.width; 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>"); }); });}
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?
When running the following url:http://localhost:(portnumber)/proxy/proxy.ashx?http://(url)/arcgis/rest/services/(ServiceName)/FeatureServer/0/4314 I get the following error:
{error: {code: Forbidden,message:"Proxy is being used for an unsupported service: above url^^)
I don't know if this might help.
Nalyd,
Is the url ht tp://(url)/arcgis/rest/services/ added to your proxy.config? Have you tested your proxy to make sure it is still working.
ht tp://localhost:[portnumber]/proxy/proxy.ashx?ping
When I added it to the proxy.config and attempted to open the url it took me to the page related to the feature, however when I then clicked on the add attachment button from on that page it told me page not found and I noticed that the url turned into http://localhost:(portnumber)/arcgis/rest/services/(ServiceName)/FeatureServer/0/4314/AddAttachments - it took away the part of the proxy and the host service url.
When I ran the url: http://localhost:24698/proxy/proxy.ashx?ping I got the following error message: {error: {code: Forbidden,message:"Proxy is being used for an unsupported service: ping"}}
The following is my config file:
<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
mustMatch="true">
<serverUrls>
<serverUrl url="https://maps.googleapis.com" matchAll="true"/>
<serverUrl url="http://localhost/eGIS.API" matchAll="true" />
<serverUrl url="http://localhost:40580" matchAll="true" />
<serverUrl url="http://localhost:41263" matchAll="true" />
<serverUrl url="http://localhost" matchAll="true" />
<serverUrl url="http://localhost:82" matchAll="true" />
<serverUrl url="http://localhost:24698" matchAll="true" />
<serverUrl url="http://url:8030/arcgis/rest/services" matchAll="true" />
<serverUrl url="http://10.201.100.81/arcgis/" matchAll="true" />
<serverUrl url="https://www.arcgis.com/home" matchAll="true" />
</serverUrls>
</ProxyConfig>