Restangular - PUT 请求负载作为查询字符串参数发送

Restangular - PUT request payload is being sent as query string parameters

我正在使用矩形并且有这样的东西:

stuffResource = parentResource
          .one(resources.category, $scope.stuff.category)
          .one(resources.stuff, $scope.stuff.id)
          .put($scope.stuff);

现在,发送请求时,我的 "stuff" 对象将在查询字符串中而不是正文中发送!

我做错了什么?

您在这里要做的是使用 customPUT() 而不是普通的 put()。

stuffResource = parentResource
    .one(resources.category, $scope.stuff.category)
    .one(resources.stuff, $scope.stuff.id)
    .customPUT($scope.stuff);

来自文档

  • put([queryParams, headers]): 对当前元素做一个put

  • customPUT([elem, path, params, headers]):对特定路径执行 PUT。您可以选择设置 params 和 headers 以及 elem。 Elem 是 post 的元素。如果未设置,则假定它是您从中调用此函数的元素本身。