0

我正在使用 Push Woosh 发送推送通知。我正在对其进行测试并尝试通过 Ajax Post 创建一条新消息,但我收到了错误的请求错误。

遵循https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-Method-messages-create上的说明

这是我的代码:

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);
              }
          });
4

1 回答 1

0

我通过首先对数据进行字符串化解决了同样的问题:

data: JSON.stringify(data) 

代替

data: data
于 2015-03-09T18:41:24.070 回答