簡體   English   中英

JavaScript SDK上的Parse Push Rest API出現400錯誤的請求錯誤

[英]400 Bad Request Error with Parse Push Rest API on JavaScript SDK

我的Ionic應用程序遇到問題。 我試圖利用Rest API通過Parse發送推送通知。 我可以使用他們的推送控制台成功發送通知。

但是,以下函數將引發錯誤代碼115和一條消息,提示“錯誤:“缺少推送數據。”如果您需要任何其他信息來解決此問題,請告訴我。
謝謝。

$scope.send = function()


{
    $http({
      url: "https://api.parse.com/1/push",
      method: "POST",
      data: {
        "alert": "Alert Message", //not platform specific
        "badge": "1", //platform specific iOS
        "sound": "", //platform specific iOS
        "channels":["test"] 
      },
      headers: {
        "X-Parse-Application-Id": "removed",
        "X-Parse-REST-API-Key": "removed",
        "Content-Type": "application/json"
      }
      }).success(function (data, status, headers, config) {
              console.log("Push sent!");
                  //alert('iOS registered success = ' + data + ' Status ' + status); 
          }).error(function (data, status, headers, config) {
              console.log(config)
    });

  };

我想出了一個解決方案。 以下與REST API一起使用:

$scope.send = function()


{
    $http({
      "url": "https://api.parse.com/1/push",
      "method": "POST",
      "data": {
          "data": { "alert": "Alert Message", "sound": "", "badge": "Increment" },"channel":""
         // this line needed correct JSON formatting
      },
      "headers": {
          "X-Parse-Application-Id": "removed",
          "X-Parse-REST-API-Key": "removed",
          "Content-Type": "application/json"
      }
  }).success(function (data, status, headers, config) {
              console.log("Push sent!");
                  //alert('iOS registered success = ' + data + ' Status ' + status); 
          }).error(function (data, status, headers, config) {
              console.log(config)
    });

  };

我沒有正確的JSON鍵值格式。 希望當使用Angular通過Parse REST API發出HTTP POST請求時,這對其他人有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM