public async Task <SiteScriptMetadata> CreateAsync(SiteScriptMetadata siteScriptMetadata, CancellationToken cancellationToken) { if (siteScriptMetadata == null) { throw new ArgumentNullException(nameof(siteScriptMetadata)); } if (string.IsNullOrEmpty(siteScriptMetadata.Title)) { #pragma warning disable CA1303 // Do not pass literals as localized parameters #pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentOutOfRangeException(paramName: nameof(siteScriptMetadata.Title), message: "Title must be provided"); #pragma warning restore CA2208 // Instantiate argument exceptions correctly #pragma warning restore CA1303 // Do not pass literals as localized parameters } var title = HttpUtility.UrlEncode(siteScriptMetadata.Title); var desc = HttpUtility.UrlEncode(siteScriptMetadata.Description ?? string.Empty); var segment = $"Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.CreateSiteScript(Title=@title,Description=@description)?@title='{title}'&@description='{desc}'"; this.AppendSegmentToRequestUrl(segment); this.ContentType = "application/json"; var newEntity = await this.SendAsync <SiteScriptMetadata>(siteScriptMetadata.Content, cancellationToken).ConfigureAwait(false); return(newEntity); }
public Task <SiteScriptMetadata> CreateAsync(SiteScriptMetadata siteScriptMetadata) { return(this.CreateAsync(siteScriptMetadata, CancellationToken.None)); }