public async Task <IActionResult> Youtube([FromBody] JObject request) { var watch = System.Diagnostics.Stopwatch.StartNew(); string methodName = "Youtube"; ResponseDTO response = new ResponseDTO(); try { Log.Write(appSettings, LogEnum.DEBUG.ToString(), label, className, methodName, $"REQUEST: {JsonConvert.SerializeObject(request)}"); switch (request["operation"].ToString()) { case "search": response.Result = await YoutubeService.Search(appSettings, request); break; case "commentThreads": response.Result = await YoutubeService.CommentThreads(appSettings, request); break; default: break; } response.Success = true; watch.Stop(); Log.Write(appSettings, LogEnum.INFO.ToString(), label, className, methodName, $"RESULT: {JsonConvert.SerializeObject(response)} Execution Time: {watch.ElapsedMilliseconds} ms"); return(Ok(response)); } catch (Exception e) { response.Success = false; response.Msg = e.Message; watch.Stop(); Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {JsonConvert.SerializeObject(request)}"); Log.Write(appSettings, LogEnum.ERROR.ToString(), label, className, methodName, $"ERROR: {e.Source + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace}"); return(BadRequest(response)); } }