Trying simple JS code to pull in a CSV ; works in sandbox, not outside

1971
2
02-22-2016 01:35 PM
artHeyman
New Contributor

Still a newbie here- trying simple JS code to pull in a CSV.  It works in the sandbox but neither on my local server or pulled from a company web server.

https://  developers.arcgis.com/javascript/jssamples/layers_csv.html  I get:

n {message: "Unable to load /proxy/?http://earthquake.usgs.gov/…quakes/feed/v1.0/summary/2.5_week.csv status: 404", response: Object, status: 404, responseText: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">…was not found on this server.</p>↵</body></html>↵", xhr: XMLHttpRequest…}_ssl: undefinedlog: undefinedmessage: "Unable to draw graphic (null): Unable to load /proxy/?http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_week.csv status: 404"response: ObjectresponseText: "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">↵<html><head>↵<title>404 Not Found</title>↵</head><body>↵<h1>Not Found</h1>↵<p>The requested URL /proxy/ was not found on this server.</p>↵</body></html>↵"stack: (...)get stack: get stack()set

Tags (1)
0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

Do you have a proxy on your server? Take a look at this page for more information about them. Esri has create different proxies that you can set up on your server: GitHub - Esri/resource-proxy: Proxy files for DotNet, Java and PHP.

YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Art,

The issue is you need to add a proxy in order to load csvfile that not coming from your local server domain. If you check this API document: CSVLayer | API Reference | ArcGIS API for JavaScript

It said that "If CSV files are not on the same domain as your website, a CORS enabled server or a proxy is required. "

Therefore you need to implement a proxy in your local server and in the code point to the proxy.ashx file.

For example, instead in the sandbox

esriConfig.defaults.io.proxyUrl = 'http://serverapi.arcgisonline.com/proxy/proxy.ashx'

You should point to your local server proxy url:

esriConfig.defaults.io.proxyUrl = 'http://yourlocaldomain.com/yourProxyFolderName/proxy.ashx'

You can download the Esri resource proxy from here: GitHub - Esri/resource-proxy: Proxy files for DotNet, Java and PHP.

For more detail about how to setup proxy, you can follow this Esri blog:

Setting up a Proxy | Support Services Blog

Hope this can help.