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.
<SPAN class="keyword token">function</SPAN> <SPAN class="token function">myCallbackFunction</SPAN><SPAN class="punctuation token">(</SPAN>ioArgs<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
ioArgs<SPAN class="punctuation token">.</SPAN>headers<SPAN class="punctuation token">.</SPAN>Accept <SPAN class="operator token">=</SPAN> <SPAN class="string token">"application/json;odata=verbose"</SPAN>
<SPAN class="keyword token">return</SPAN> ioArgs<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
esriRequest<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setRequestPreCallback</SPAN><SPAN class="punctuation token">(</SPAN>myCallbackFunction<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> requestSHP <SPAN class="operator token">=</SPAN> <SPAN class="token function">esriRequest</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fserver.domain%2F_api%2Fweb%2Flists%2FGetByTitle%28%2527AttachmentReason%2520Type%2527%29%2Fitems" target="_blank">https://server.domain/_api/web/lists/GetByTitle(%27AttachmentReason%20Type%27)/items</A><SPAN>"</SPAN></SPAN><SPAN class="punctuation token">,</SPAN>
handleAs<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"json"</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>