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("",{



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("", {


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.

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.