简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM