# ArcGISRestLayer URI Returning 404 Error

**URL:** <https://community.thinkgeo.com/t/arcgisrestlayer-uri-returning-404-error/8464>\
**Category:** WinForms\
**Created:** [March 22, 2017, 3:36pm UTC](https://community.thinkgeo.com/t/arcgisrestlayer-uri-returning-404-error/8464 "2017-03-22T15:36:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [March 22, 2017, 3:36pm UTC](https://community.thinkgeo.com/t/arcgisrestlayer-uri-returning-404-error/8464/1 "2017-03-22T15:36:30Z")

</div>

Hello,

We are trying to use the ArcGISRestLayer to view data on our map, with the following code. When the Map.Refresh line gets hit, a 404 Not Found error is thrown:

```
    Dim arcGisLayer As New ArcGISServerRestLayer
    arcGisLayer.ServerUri = New Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export")

    ' Sets our parameters for image format.
    arcGisLayer.Parameters.Add("format", "png")
    arcGisLayer.ImageFormat = ArcGISServerRestLayerImageFormat.Png '; // we can use the Property 'ImageFormat' instead of the 'format' in parameters. When they coexist, the property is perferred.

    ' Sets our parameters for transparency.
    arcGisLayer.Parameters.Add("transparent", "true")

    ' Specifies the layerId(s) you wish to display. LayerId 2 is the county layer.
    arcGisLayer.Parameters.Add("layers", "show:2")

    ' Specifies the layer and field you wish to query(layerid: field). in this example, the layerid is 2 and the data field to query is POP1999.
    arcGisLayer.Parameters.Add("layerdefs", String.Format("2:POP1999{0}", "> 50000"))

    'add and show
    Me._NOAAOverlay.Layers.Add(arcGisLayer)
    Me._NOAAOverlay.IsVisible = True
    Me.Map.Refresh()

```

I can go to the URL in a browser, and when I CTRL-Click it in Visual Studio, the page comes up with data. Am I missing something in the code?

Dib

---

<div class="post-metadata">

**Author:** ![Ethan](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ethan/32/19964_2.png) [@Ethan](https://community.thinkgeo.com/u/Ethan)\
**Post date:** [March 23, 2017, 3:19am UTC](https://community.thinkgeo.com/t/arcgisrestlayer-uri-returning-404-error/8464/2 "2017-03-23T03:19:11Z")

</div>

Hi Dib,

Here is the sample: [ThinkGeo Docs](http://wiki.thinkgeo.com/wiki/source_code_wpfeditionsample_arcgisserverrestlayer_cs_160908.zip)

The problem one of your code is the two lines cannot be used at the same time:

arcGisLayer.Parameters.Add(“format”, “png”)  
arcGisLayer.ImageFormat = ArcGISServerRestLayerImageFormat.Png ';

You have to comment one of them.

The problem two is you hadn’t set the current extent:

winformsMap1.CurrentExtent = New RectangleShape(-140, 60, -58, 30)

Add correct extent it works.

 ![](https://community.thinkgeo.com/uploads/default/original/3X/8/6/86e6c3f0bc2e7c5753ac948973f3b5a4c1127891.png)

Regards,

Don
