How to Upload Files on NextCloud Using Python and get the Download Link?

I am trying to upload files on my NextCloud using GitHub - owncloud/pyocclient: ownCloud client library for Python as it’s recommended all over the place. I’m trying to use their official code, but some part of it isn’t working.
This part of code is working -
import owncloud

oc = owncloud.Client('http://domain.tld/owncloud')

oc.login('user', 'password')

oc.mkdir('testdir')

oc.put_file('testdir/remotefile.txt', 'localfile.txt')

But the below part isn’t-

link_info = oc.share_file_with_link('testdir/remotefile.txt')

print("Here is your link: " + link_info.get_link())

It throws an error -

in share_file_with_link ‘name’: data_el.find(‘name’).text
AttributeError: ‘NoneType’ object has no attribute ‘text’

So, I am not getting the downloadable link. Also when I try to again re-run the script, it stops at mkdir as the folder already exists. So, can you please tell me what command I need to get the download link and how can I know if the folder is already created?

Also, I am not alone, see here - Sharing a directory · Issue #218 · owncloud/pyocclient · GitHub