admin管理员组文章数量:1356914
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.
本文标签: javascriptIssue with HTTP Request with Patch method in Angular JSStack Overflow
版权声明:本文标题:javascript - Issue with HTTP Request with Patch method in Angular JS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744040518a2580574.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论