【问题标题】:how to add user to openfire by angularjs $http using OF RestApi?如何使用 OF RestApi 通过 angularjs $http 将用户添加到 openfire?
【发布时间】: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


【解决方案1】:

这是我的愚蠢错误女巫我没有关闭我的restapi。 我必须走这条路并启用它:

OpenFire 管理面板 > 服务器 > 服务器设置 > 并检查 启用

【讨论】:

    猜你喜欢
    • 2011-09-11
    • 2012-02-08
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 2017-02-08
    • 2014-09-01
    相关资源
    最近更新 更多