我正在使用Push Woosh发送推送通知。我正在测试它并试图通过Ajax Post创建一条新消息,但是我收到了错误请求错误。
的说明这是我的代码:
data = {
"request": {
"application": "5D6E8-2E383",
"auth": "...",
"notifications": [
{
"send_date": "now",
"ignore_user_timezone": true,
"content": "este es un test de ajax",
"platforms": [3],
"apns_trim_content": 1,
"android_root_params": {
"key": "APA91bHuRB56xKAdocTZubHC1BtvNogDE_YswmluQ0mDpOSz9nRhdMbPYXngNckloqik9PEb_MqXJd1BoGpqMjwo9ntcgKOeDA4sH1IxwEl2ZJcx94FTdk22KR86FZMYogbXrtCA8U1KC3oShPab13B3NvkSu2Bphw"
},
"android_header": "Este es el titulo",
"devices": [
"APA91bHuRB56xKAdocTZubHC1BtvNogDE_YswmluQ0mDpOSz9nRhdMbPYXngNckloqik9PEb_MqXJd1BoGpqMjwo9ntcgKOeDA4sH1IxwEl2ZJcx94FTdk22KR86FZMYogbXrtCA8U1KC3oShPab13B3NvkSu2Bphw"
]
}
]
}
};
$.ajax({
type: "POST",
url: "https://cp.pushwoosh.com/json/1.3/createMessage",
data: data,
dataType: "json",
error: function(data){
console.log(data);
},
success: function(data){
console.log(data);
}
});
答案 0 :(得分:0)
我通过首先对数据进行字符串化解决了同样的问题:
data: JSON.stringify(data)
而不是
data: data