danielrvt
danielrvt

Reputation: 10926

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?

Upvotes: 1

Views: 1926

Answers (1)

Joshua Kelly
Joshua Kelly

Reputation: 1063

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.

Upvotes: 2

Related Questions