Greetings!!I have been tasked with adding an Authorization header to our layer query request.
Referencing Solved: Re: How to set headers for esriRequest using .setR... - Esri Community I managed to get the setRequestPreCallback set and the Authorization header added. However, when the callback function is fired, it only has 4 of the 9 needed query parameters for the link to work. Is there a method of recovering the missing query parameters?? We are using arcgis 3.14.
Thank you,
-Daniel
In 3.14 you can’t. esri.config.defaults.io.setRequestPreCallback fires before ArcGIS JS finalizes the request, so you’ll only see a partial content object; the library appends the rest (e.g., f, where/outFields, token, cache-buster, JSONP bits) after your callback. There’s no API to “recover” those missing params in that hook.
Practical options:
Use a proxy to add the Authorization header server-side. This is the most reliable with 3.x (no CORS/header headaches, no param timing issues).
Bypass QueryTask/FeatureLayer and call the endpoint yourself with esri.request, where you supply the full payload and header:
require(["esri/request"], function(esriRequest){ esriRequest({ url: layerUrl + "/query", content: { where: "GlobalID='" + guid + "'", outFields: "*", returnGeometry: false, f: "json" }, headers: { "Authorization": "Bearer " + token } }, { usePost: true }).then(handle, err); });
Upgrade (if you can) to a later 3.x or 4.x, where header handling and CORS behavior are cleaner. Still, for 3.x the proxy remains the simplest fix.
Keep using the pre-callback only to inject the header; don’t rely on it to inspect the final query. If you need to see/shape every param, build the request yourself or proxy it.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.