400 Error - adding hosted feature layer view to the app

605
4
09-03-2021 07:09 AM
ChitraKrishnan
New Contributor III

Hi,

I am getting 400 error while adding hosted feature layer view to the app. Any tip on how to do this is much appreciated!! 

  var basemapLayer = new ArcGISTiledMapServiceLayer(basemap.url, {
                    id: "defaultBasemap",
                    visible: true
                });

 var dynSvc = new ArcGISDynamicMapServiceLayer("https://services8.arcgis.com/HPJsu0I9OjNDnQ7I/arcgis/rest/services/tl_2020_42_tabblock20_ViewLayer/FeatureServer",
                    {
                        "opacity": 0.5
                    });
this.map.addLayers([basemapLayer, dynSvc])

 

 

Thanks

Chitra

 

0 Kudos
4 Replies
CourtneyMenikheim
Occasional Contributor

It looks like this Feature Layer requires credentials to access.
Does your application expect the user to sign in? If so, should every user able to access the application also be able to access that feature service, or only certain users?
Alternatively, does the application not have a sign in, and anyone using the application should be able to view the layer?

Courtney Menikheim | Application Developer | @thecmenikheim
0 Kudos
JohnGrayson
Esri Regular Contributor

The URL seems to be for a FeatureLayer so try:

var dynSvc = new FeatureLayer("https://services8.arcgis.com/HPJsu0I9OjNDnQ7I/arcgis/rest/services/tl_2020_42_tabblock20_ViewLayer/FeatureServer/0", {"opacity": 0.5});

 

0 Kudos
ChitraKrishnan
New Contributor III

Hi,

Thanks for the reply. I set the share level to public. After setting it as a featurelayer the error is gone. But the layer is not visible on the map. Any thought on this?

Thanks

Chitra

 

0 Kudos
JohnGrayson
Esri Regular Contributor

The layer displays via the online Map Viewer, but there are many complex features at the default minimum scale, so you might want to adjust it so the feature visibility is more appropriate for the type of data.

JohnGrayson_0-1630708670346.png

0 Kudos