I cannot create groups via web API in seafile

233 views
Skip to first unread message

Sergio Gayarre Garasa

unread,
Aug 25, 2014, 6:40:16 AM8/25/14
to sea...@googlegroups.com
Hi, I am trying to create a group in seafile via webapi, but I am not able to get it work, I am obtaining an error that says that method put is not allowed, could it be because the user does not have enough permissions (but I do no think so, because in the frontend I can create them without any problem with the same user), what concerns me is that in the doc says that should be done by "PUT". I am using a curl class to to this an I am only having this issue on the method for groups. Can anybody help me? Any help would be really appreciated.

        $data = array("group_name"=>"newgroup");
        $url = $this->sUrl."/api2/groups/";
   
        $this->setHeaderToken();
        $this->put($url,$data);
  
        var_dump($this->response);

Impiastro

unread,
Sep 1, 2014, 8:44:29 AM9/1/14
to sea...@googlegroups.com
I checked the seahub api2 code of the master branch and it seems still possible to add a group.

If the user hasn't the right permissions an error 403 will be raised.
The PUT method is supported by the GroupsView (you can read it from here):

https://github.com/haiwen/seahub/blob/master/seahub/api2/views.py#L2571

This is code for a python script:

        base_host = 'https://<yourserver>/'
        base_url = base_host + 'api2/'
        groups_service_path = 'groups/'
        opener = urllib2.build_opener(urllib2.HTTPHandler)
        data = urllib.urlencode({
                                 'group_name' : test_group_newname
                                 })
        req = urllib2.Request(base_url + groups_service_path, data)
        req = _add_common_header(req)
        req = _add_token_header(req, token)
        req.get_method = lambda: 'PUT'
        res = opener.open(req)
        resp_obj = json.loads(res.read())
        resp_headers = res.info()
        resp_code = res.getcode()
        print ""
        print "group created response code: " + str(resp_code)
        print "group created id: " + str(resp_obj["group_id"])
        print "group created success: " + str(resp_obj["success"])
        group_id = str(resp_obj["group_id"])

JackTh38

unread,
Sep 18, 2014, 12:18:51 PM9/18/14
to sea...@googlegroups.com
Hi,

I have the same problem. When issuing :
curl -v -X PUT -d "group_name=newgroup" -H 'Authorization: Token 3d0d79a6a0dea605ab9692c7c16d7564d4dc508c'  "https://seafile.myserver.com/api2/groups/"
I get a "Page unavailable" "Sorry, but the requested page is unavailable due to a server hiccup"
The user is an administrator in the seafile, he can create users even through web API, ....
In seahub_django_request.log, I get the following error :
[ERROR] django.request:212 handle_uncaught_exception Internal Server Error: /api2/groups/
Traceback (most recent call last):
  File "/home/seafile/seafile-server-3.1.6/seahub/thirdpart/Django-1.5.1-py2.6.egg/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/seafile/seafile-server-3.1.6/seahub/thirdpart/Django-1.5.1-py2.6.egg/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/seafile/seafile-server-3.1.6/seahub/thirdpart/Django-1.5.1-py2.6.egg/django/views/decorators/csrf.py", line 77, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/seafile/seafile-server-3.1.6/seahub/thirdpart/rest_framework/views.py", line 363, in dispatch
    response = self.handle_exception(exc)
  File "/home/seafile/seafile-server-3.1.6/seahub/thirdpart/rest_framework/views.py", line 360, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/seafile/seafile-server-3.1.6/seahub/seahub/api2/views.py", line 2597, in put
    checked_groups = get_personal_groups_by_user(username)
UnboundLocalError: local variable 'username' referenced before assignment


Seafile server is 3.1.6 on Debian, with nginx and HTTPS

Does anyone already faced this ?

Thanks
Jack

Daniel Pan

unread,
Sep 18, 2014, 11:27:06 PM9/18/14
to sea...@googlegroups.com
This is a bug that fixed but not published yet.

Gotardo González Quero

unread,
Sep 19, 2014, 11:38:09 AM9/19/14
to sea...@googlegroups.com
Hi, I am getting the very same error. 
@Daniel, do you know if there is a release date for the bug fix?
Thanks a lot.

Sergio Gayarre Garasa

unread,
Sep 22, 2014, 6:07:48 AM9/22/14
to sea...@googlegroups.com

Hi There, I just want to say that I am allowed to create groups from the original sea cloud server, using their server (seacloud.cc) However after installing seafile on our own server, the groups creation and managing I do not think is supported properly. The webserivce es properly set up as it accepts callings by PUT, but it returns a error 500. I am concern because I am not having this issue with other methods. Daniel you are talking about a bug, can you give us further details please?

Sergio Gayarre Garasa

unread,
Sep 26, 2014, 7:06:15 AM9/26/14
to sea...@googlegroups.com
Ey there anybody knows why I cannot create groups after installing NGINX with seafile on our own server? my method is okay as I am not having issues with the original seacloud server. Is there any bug known about this?


El lunes, 25 de agosto de 2014 12:40:16 UTC+2, Sergio Gayarre Garasa escribió:

JackTh38

unread,
Nov 6, 2014, 8:23:50 AM11/6/14
to sea...@googlegroups.com
The bug is fixed in the 3.1.7 version

Thanks a lot

Jack
Reply all
Reply to author
Forward
0 new messages