Sharepoint REST API - SP.Web.CreateAnonymousLink - Unable to CREATE Links
Question
In short - the issue appears to be that I can access a folder or file's anonymous link - but only after it's been created. When I say created - I mean clicking the 'copy link' button as show in the screen. (Also works fine if a Flow creates it)
If that's been done, then using the REST API to get the anonymous link works fine:
Header
Body
Response
If I try and 'create' a link for a new file though;
Bad response
So where are my permissions failing me? You may have noticed that I don't pass the X-RequestDigest. That's because it doesn't seem to do anything. Without it I can upload and do whatever I need - with it, I gain no new permissions.
The app that I'm using to authenticate against has what I think is full control over the SharePoint site. As seen in this page's example:
Is there anything I'm missing? Why wouldn't I be able to create an anonymous link through the API but I can access it if someone else has already created it?
Thanks for your time.
Solution
I had the same issue.
Started working for me when I updated app permissions to
<AppPermissionRequests AllowAppOnlyPolicy="true"> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" /> <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" /> <AppPermissionRequest Scope="http://sharepoint/social/tenant" Right="Read" /> <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" /> </AppPermissionRequests>