Skip to content

Question: How to use the custom API Request to generate an AnonymousLinkWithExpirationDate #798

Answered by Ironbell
Ironbell asked this question in Q&A
Discussion options

You must be logged in to vote

Found my own answer after trying for quite a bit, just in case anyone needs it :)

private static string GetFileAccessUrl(PnPContext context, string serverRelativeUrl)
{
    var host = context.Uri.Host;
    var scheme = context.Uri.Scheme;
    
    var url = $"{scheme}://{host}{serverRelativeUrl}";
    var expirationString = DateTime.Now.AddDays(1).ToString("s", System.Globalization.CultureInfo.InvariantCulture);
    var isEditLink = false;
    
    var request = new
    {
        url,
        isEditLink,
        expirationString,
    };

    var body = JsonConvert.SerializeObject(request, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

    var apiRequest = n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ironbell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant