public async Task <JsonResult> fetchOpenGraph(string url) { if (string.IsNullOrEmpty(url)) { return(new JsonResult(null)); } if (!Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) { return(new JsonResult(null)); } if (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps) { return(new JsonResult(null)); } if (!(await _service.FetchOpenGraph(url) is OpenGraph og)) { return(new JsonResult(null)); } var output = new Dictionary <string, string>(); og.Metadata.Select(m => m.Value) .Select(m => m.FirstOrDefault()).ToList() .ForEach(meta => { output[meta.Name] = meta.Value; }); return(new JsonResult(output) { ContentType = "application/json", StatusCode = StatusCodes.Status200OK }); }