AnsweredAssumed Answered

Problems using map.addLayer with own AGOL map service, but works OK with sample server - 400 bad request

Question asked by janweststeyn on Aug 6, 2018

Hi there,

 

I'm very new to working with the javascript API and widget dev. but I'm experimenting with some sample code and have been getting on reasonably well until trying to use my own data. I'm calling map.addLayer

 

var externalMapLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer",{
});
this.map.addLayer(externalMapLayer);

 

 

This works great with the sample map from my widget - I was quite pleased with myself.

 

If however, I try this with a map server I've got in my organisations AGOL account:

 

var externalMapLayer = new ArcGISDynamicMapServiceLayer("https://services3.arcgis.com/3wBYLDMc7IlzsBlJ/arcgis/rest/services/servicenamehere/MapServer/", {

});
this.map.addLayer(externalMapLayer);

I get a 400 bad request error. I can see it is correctly passing in the token (which works), and that there are a bunch of other params in there.

 

https://services3.arcgis.com/3wBYLDMc7IlzsBlJ/arcgis/rest/services/FlatPlaysNorthSea(Tiles)/MapServer/1/export?dpi=96&transparent=true&format=png8&token=xyz&bbox=-4082035.6336174808%2C6042764.95803646%2C721878.7200479996%2C9560091.251606196&bboxSR=102100&imageSR=102100&size=982%2C719&f=image

token replaced with xyz, but i've verified its ok.

If I remove all params I get: token required

If I add the token only I get: Invalid URL

If I add other params (e.g. f=image), I get: Bad Request

Can anyone help work out what is different between the AGOL service I set up and the sample services..

Using API 3.25.

 

I've been succesfully using queryTask to query my own service in AGOL, although that is a feature server on a different path.

 

Thanks for your help in advance.

Outcomes