Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

Obtaining sharing links

Open davidorme opened this issue 4 years ago • 5 comments

I am trying to use the package to create sharing links. I can successfully connect to my site and access folder and files but can't find the API to create a link. I've had a quick look through the functions and classes in office365.sharepoint.files.file but I think I'm looking in the wrong part of the object model.

Apologies for posting questions on the issue tracker, but can you give me a pointer?

davidorme avatar Feb 17 '21 10:02 davidorme

Hey, I am walking through the same issue. Did you find a solution?

GeoLegalTech avatar Dec 06 '21 14:12 GeoLegalTech

I did not, sorry.

davidorme avatar Feb 01 '22 08:02 davidorme

Thanks for the answer, I found a way to do it.

GeoLegalTech avatar Feb 01 '22 11:02 GeoLegalTech

If you could post an example of the code, that would be fantastic!

davidorme avatar Feb 01 '22 11:02 davidorme

I will prepare it in the next days

GeoLegalTech avatar Feb 01 '22 11:02 GeoLegalTech

Hi,

although this is the relatively old thread, but in case if anyone stumble upon it, here is an example how to create a sharing link for the file:

ctx = ClientContext(site_url).with_credentials(user_credentials)
file = ctx.web.get_file_by_server_relative_url("Shared Documents/Archive/Report.xlsx")

result = file.share_link(SharingLinkKind.AnonymousView).execute_query()

print(result.value.sharingLinkInfo.Url)

A complete example could be found here and a few more examples could be found in examples section.

vgrem avatar Aug 23 '23 13:08 vgrem