1

I have a simple ASP.NET Web API 2 service. I'm new at Angular, but I'm trying to switch from using $http to Restangular. My GET appears to be fine, but my POST is not.

The code looks like this:

    $scope.addLift = function () {
    $http.post(url, $scope.Lift);
    //Restangular.all('lifts').post('Lift', $scope.Lift).then(function (newLift) {
    //    $scope.getLifts();
    //}, function (error) {
    //    console.log(error);
    //});
};

The commented out Restangular code does not work, but the $http.post does and I'm not sure what I'm doing wrong.

If it's helpful, the POST when using Restangular is http://localhost/api/lifts?LiftName=test where in the $http POST request, it does not contain the parameters on the URL line, it seems the data is in the request body.

0

1 Answer 1

1

Someone on another website was kind enough to help me through this. Thought I would post the answer in hopes that it might benefit others.

Restangular.all('lifts').post($scope.Lift).then(function (newLift) {
        $scope.getLifts();
    }, function (error) {
        console.log(error);
    });

The additional 'lift' argument was not necessary in the post call.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.