如何在owncloud中使用外部API创建用户

时间:2017-02-15 07:45:55

标签: owncloud

我的应用程序使用外部API创建owncloud用户。

我尝试使用外部API获取owncloud版本。以下是我使用的代码:

 $.ajax({
                type: 'GET',
                url: 'http://localhost/owncloud/index.php/apps/news/api/2.0/version',
                contentType: 'application/json',
                success: function (response) {
                    // handle success
                },
                error: function () {
                    // handle errors
                },
                beforeSend: function (xhr) {
                    var username = 'admin';
                    var password = 'admin';
                    var auth = btoa(username + ':' + password);
                    xhr.setRequestHeader('Authorization', 'Basic ' + auth);
                }
            });

上面的代码没有用。

如何实现这一目标?

提前致谢。

1 个答案:

答案 0 :(得分:-1)

您输入的代码是正确的。

您还可以测试您的api是否使用postman或chrome rest client返回数据。

然后(函数(响应){                 $就({                     url:url,                     类型:“POST”,                     dataType:“json”,                     contentType:“application / json”,                     data:JSON.stringify(data),                 })                 .done(function(res){                     swal(“已删除!”,“您的ListJds已被删除。”,“成功”);

            })
            .error(function(res) {
                res;
                swal("Delete Failure!", "Please Try Again.", "error");
            });
        })  
相关问题