8

Following is my code:

  $http({
      url: 'https://apistage.dealsignal.com/api/v0/company_watchlists/' + wishlist_id,
      method: 'PATCH',
      params: {
          list: {
              add_company_ids: ['61737'],
              name: 'My Wishlist'
          },
          api_key: 'CtxY3Kpc7ZDL8VDfLmPt9wss'
      }
  })
      .success(function(response) {
          console.log(response);
      }).
  error(function(response) {
      console.log(response);
      return false;
  });

I am getting bad request error but same request with patch method is working in REST CLIENT on chrome.

1
  • 2
    Most of the time when a request fails from the browser, but succeeds in a Postman or another REST client, it means that CORS in the server is not set correctly. Commented Sep 22, 2015 at 11:21

2 Answers 2

7
+25

Please see the Angular Doc. This will be Data not params.

$http({
  url: 'https://apistage.dealsignal.com/api/v0/company_watchlists/' + wishlist_id,
  method: 'PATCH',
  data: {
      list: {
          add_company_ids: ['61737'],
          name: 'My Wishlist'
      },
      api_key: 'CtxY3Kpc7ZDL8VDfLmPt9wss'
  }
}).success(function(response) {
      console.log(response);
  }).
  error(function(response) {
  console.log(response);
  return false;
});
Sign up to request clarification or add additional context in comments.

1 Comment

I am trying to utilize this answer, but my back-end doesn't receive anything from the data parameter. Any ideas? Originally I tried using $resource, but have the same issue. (stackoverflow.com/questions/33917898/…)
2

I am not sure about it, but may be the problem is that the parameter "params" should be named "data", as when you make a POST request.

Hope it helps.

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.