In ArcGIS Server 10.1 rest api response header content-type is set to text/plain when the request is for json. In later versions of ArcGIS Server can the content-type be set to application/json for a rest service response? Trying to use Springs HttpMessageConverter to map json response to Java object, but it relies on the Content-type header of response.
Hi, I am using arcgis server 10.3 and it seems we cannot set the request header Content-type to application/json.
See this real example:
var postData = {"foo": "bar", "f": "json"};
var xhr = new XMLHttpRequest();
xhr.open("POST", https://mydomain.com/arcgis/rest/services/DEV/testService/GPServer/test/execute , true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
resolve(JSON.parse(xhr.response));
}
}
xhr.send(JSON.stringify(postData));
Here is the Response Header:
Access-Control-Allow-Origin: http://localhost:8080
Cache-Control: max-age=0,must-revalidate, max-age=60
Connection: Keep-Alive
Content-Type: text/html;charset=utf-8
Date: Thu, 19 Jan 2017 18:21:59 GMT
Expires: Thu, 19 Jan 2017 18:25:32 GMT
Keep-Alive: timeout=15, max=100
Server:
Set-Cookie: sto-id-47873-cartod=CHHFBJKMFAAA; Domain=mydomain.com; Expires=Sun, 17-Jan-2027 18:21:59 GMT; Path=/
Transfer-Encoding: chunked
Vary: Origin
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
access-control-allow-credentials: true
Here is the Request Header:
Host: mydomain.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
origin: http://localhost:8080
DNT: 1
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
And nothing appears in the posted params. Nothing is posted, nothing in the response neither.
I think I misread your question, I though you were actually wanted to post data as json string.
I dont know if you can change some parameters in arcgis server but by default the ResponseHeader Content-type is set to "application/x-www-form-urlencoded" when using the json output format.