Following is my code:
$http({
url: '/' + wishlist_id,
method: 'PATCH',
params: {
list: {
add_pany_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.
Following is my code:
$http({
url: 'https://apistage.dealsignal./api/v0/pany_watchlists/' + wishlist_id,
method: 'PATCH',
params: {
list: {
add_pany_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.
Share Improve this question edited Sep 15, 2015 at 10:46 Manish Kr. Shukla 4,4771 gold badge21 silver badges35 bronze badges asked Sep 15, 2015 at 10:44 Seema SharmaSeema Sharma 893 bronze badges 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. – Ori Drori Commented Sep 22, 2015 at 11:21
2 Answers
Reset to default 7 +25Please see the Angular Doc. This will be Data not params.
$http({
url: 'https://apistage.dealsignal./api/v0/pany_watchlists/' + wishlist_id,
method: 'PATCH',
data: {
list: {
add_pany_ids: ['61737'],
name: 'My Wishlist'
},
api_key: 'CtxY3Kpc7ZDL8VDfLmPt9wss'
}
}).success(function(response) {
console.log(response);
}).
error(function(response) {
console.log(response);
return false;
});
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.