【发布时间】:2016-09-18 13:07:39
【问题描述】:
我正在使用 OpenFire Rest APi v 1.2.3 添加新成员。这是我发送请求的代码。
var par ={
username:$scope.currentItem.tel1,
password:buildKey($scope.currentItem.password),
name:$scope.currentItem.name,
email: $scope.currentItem.email
};
$http({
method: "POST",
url: baseCfg.xmpp_server + "users",
headers: {
"Content-Type": "application/json",
"Authorization":"Basic YWRtaW46IVFBWjFxYXo="
},
data:JSON.stringify(par)
}).then(function () {
console.log("done");
}, function () {
console.log("error");
});
但我收到了这样的回复:
OPTIONS 403 禁止
并且在请求标头中没有标头和参数。
【问题讨论】:
-
我没用过你说的那个api,但是这个问题好像很常见,和你的客户端代码没有关系。通常,当您使用 POST 请求时,浏览器首先会发送一个预检请求(方法类型 = OPTIONS)。您的 Rest API 似乎不允许 OPTIONS 方法,应该在服务器上启用它以使其工作。
标签: angularjs rest cors openfire