esri request with use proxy and RequestPreCallback function

838
0
07-03-2017 10:48 PM
ZdeněkSoldán
Occasional Contributor

Hello

I need to send a request with a header Accept "application/json;odata=verbose" because I need an answer in JSON format. I use esri request with RequestPreCallback function and it does what I need.

function myCallbackFunction(ioArgs) {
   ioArgs.headers.Accept = "application/json;odata=verbose"
   return ioArgs;
}
esriRequest.setRequestPreCallback(myCallbackFunction);
var requestSHP = esriRequest({
   url: "https://server.domain/_api/web/lists/GetByTitle(%27AttachmentReason%20Type%27)/items",
   handleAs: "json"
}),‍‍‍‍‍‍‍‍‍

But when the request is send login pop up for authentication on this site is shown. I need all request to be send under one specific user so I want to use an esri proxy with domain, user and password parametrs for this site. I configured the proxy and into the code for esri request I add 

{
useProxy:false
}

parametr. But now the response from the request is in xml format so my header Accept is not honored. 

Can anyone help me please?

Thanks

Zdenek

0 Kudos
0 Replies