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

亡梦爱人 提交于 2019-12-11 11:59:19

问题


I'm using rectangular and have something like this:

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

Now, when the request is sent, my "stuff" object is being sent in the query string instead of the body!

What I'm I doing wrong here?


回答1:


What you want to do here is use customPUT() instead of the normal put().

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

From the docs

  • put([queryParams, headers]): Does a put to the current element

  • customPUT([elem, path, params, headers]): Does a PUT to the specific path. Optionally you can set params and headers and elem. Elem is the element to post. If it's not set, it's assumed that it's the element itself from which you're calling this function.



来源:https://stackoverflow.com/questions/30557588/restangular-put-request-payload-is-being-sent-as-query-string-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!