JQuery ajax com POST para obter image / png do servidor habilitado para CORS
Estou escrevendo um aplicativo HTML5 / Backbone / PhonegapGithub Repo que usa a API REST SensorObservationService por 52n (v1 Documentos da API). Cada GET-Request funciona bem - mas agora eu quero baixar uma imagem que é gerada após uma solicitação POST.
Mas o servidor está respondendo com status 400:
statusCode":400,"hints":["Check the message which has been sent to the server. Probably it is not valid."],"reason":"Bad Request","developerMessage":"Could not read JSON
...
Este é o meu AJAX-Call:
var body = {
"base64":true,
"legend":false,
"timespan":"2013-10-30T00:00:00Z/2013-10-30T23:59:59Z",
"width":482,
"height":568,
"language":"en",
"grid":false,
"styleOptions": {
"ts_32e1174948e46f2e46fe597eb40b3557": {
"chartType": "line",
"properties": {
"color": "#b45e87",
"lineType":"solid",
"width":1
}
}
}
};
$.support.cors = true;
this.xhr = $.ajax({
crossDomain: true,
type: "POST",
url:"http://sensorweb.demo.52north.org/sensorwebclient-webapp-stable/api/v1/timeseries/getData",
processData: false,
dataType: "json",
accept: "application/json",
contentType: "application/json; charset=utf-8",
data: body
}).done(function(data) {
}).fail(function(xhr, textStatus) {
}).always(function() {
});
Aqui está o meuviolino - Se eu tentar a mesma chamada POST com o POSTMAN, o servidor faz o que deveria.
RESTClient-Screenshot
O que há de errado com minha ligação?