Are there any examples showing how to use the .headers option for a GET request?
Opened this issue · 2 comments
alexf1 commented
trying to find documentation that shows how to format headers when doing GET request
phil-brown commented
There's not much documentation other than the javadocs for Header.java. When constructing your AjaxOptions
object, you need to pass the headers to it, and you can create those headers using any of the available methods. If you use a String, this should be formatted like JSON - for example:
AjaxOptions options = new AjaxOptions().headers(new Headers("{\"Accept\":\"application/json\"}"));
You might be able to get away without using the escaped quotation marks:
AjaxOptions options = new AjaxOptions().headers(new Headers("{Accept:application/json}"));
To add additional ones, just add a comma:
{Accept:application/json,Content-Type:application/json}
You can also pass a Map Object, an array of Header objects, or a JSONObject.
alexf1 commented
I did something like this
Headers header = new Headers();
header.add("X-SESSION-KEY",sessionkey);
header.add("X-GLOBAL-KEY", globalKey);
and then .headers(header)
If it doesn't work I'll try the methods you have and see if that works. Thanks Phil