Select to view content in your preferred language

setRequestPreCallback is partially working

2998
1
08-26-2015 03:55 PM
BradJanke
Deactivated User

I have an api sitting in front of AGS that requires it's own authentication. I am using setRequestPreCallback as stated by the ESRI docs​.

In the image below, you can see that the first 2 requests are returning 200. The first request is CORS Preflight and the second request is the JS api getting the json info from the MapServer.

setRequestCallback.png

The second request uses the function I have set in setRequestPreCallback(...) to properly set a header value with the token. However, whenever an image is requested from the MapServer (via export), the function I have in setRequestPreCallback is not called and the token is not set, leaving me with a bunch of 401 Unauthorized requests.

Any ideas?

Feel free to answer on SO as well: http://stackoverflow.com/questions/32238110/setrequestprecallback-is-partially-working

Message was edited by: Brad Janke

Tags (1)
1 Reply
RobertWinterbottom
Deactivated User

Do you have the snippet of code you are using in setRequestPreCallback ?

I think it needs to be set as a query param to the service so the request should look something like this:

MapServer?f=json&token={insert token here}&dpi=96&transparent=true&format=png8

0 Kudos