【问题标题】:400 Bad Request Error with Parse Push Rest API on JavaScript SDKJavaScript SDK 上的 Parse Push Rest API 出现 400 错误请求错误
【发布时间】:2015-08-12 06:47:40
【问题描述】:

我的 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)
    });

  };

【问题讨论】:

    标签: javascript parse-platform push-notification ionic-framework


    【解决方案1】:

    我想出了一个解决方案。以下内容适用于 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 请求时。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-12
      • 2020-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-17
      • 2016-06-20
      相关资源
      最近更新 更多