Using occ to share userA's calendar with userB?

In NC21, is there a way I could use occ to share a user’s calendar with another user ?

Ideally, I would like the personal calendars of
userA, userB, userC… to be share with a given user (“main_user”)

Obviously I can do it using the web interface but it is time consuming.
Any idea how to solve this problem ?
Best,
V

Hi @vmunich77

You could do it the other way arround. Create the calendars in the “main_user” account and share them from there with the relevant users who need access.

Hi bb77, thanks for your message.

Yes, but could I do this using occ ?
I could not find how to use occ to share users’s calendars in the documentation

Best,
V

No I don’t think thats possible.

I also found this with a quick google search…

https://github.com/nextcloud/server/issues/23509

Yes I found it too.
Too bad.
Thanks for your help.
V

If you follow @bb77 suggestion to create the calendar in the main users account you could share the calendars via a POST-request with curl (you need the main users password though):

#!/usr/bin/env bash

set -euo pipefail


###
### begin variable declaration
###

# Nextcloud-URL (add subdirectory, if Nextcloud is not in webroot):
nextcloud_url="https://www.my_nextcloud.com/"

# username who shares the calendar:
user="USERNAME"
user_password="PASSWORD"

# name of the calendar to be shared:
calendar_name="CALENDARNAME"

# username with whom the calendar will be shared:
sharee="SHAREE"

# calendar access privileges for the sharee ("read-write" or "read")
sharee_access="read-write"

###
### end of variable declaration
###


# create URL to calendar (set together with variables declared before):
calendar_url="${nextcloud_url%%/}/remote.php/dav/calendars/${user}/${calendar_name}/"

# prepare data for POST request:
data='
  <x4:share xmlns:x4="http://owncloud.org/ns">
    <x4:set>
      <x0:href xmlns:x0="DAV:">principal:principals/users/'${sharee}'</x0:href>
      <x4:'${sharee_access}'/>
    </x4:set>
  </x4:share>'

# POST request to share the calendar $calendar from $user with $sharee
curl -sS -f -k -u "${user}:${user_password}" -H "Content-Type: application/xml; charset=utf-8" -X POST "${calendar_url}" -d "${data}"

printf '%s\n' "${user}s' calendar '${calendar_name}' successfully shared with '${sharee}'."

exit 0