public async Task <ContentResult> OnPostAsync() { try { if (Request.Body != null) { using (TextReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { string jsonText = await reader.ReadToEndAsync(); System.Console.WriteLine($"Read JSON: {jsonText}"); var apiCall = ApiCall.FromJson(jsonText); var handler = new ApiHandler(_context); var result = await handler.AutoProcessAsync(apiCall); if (result is ApiError) { return(processExit(result, (result as ApiError).HttpStatusCode)); } else { return(processExit(result, 200)); } } } return(processExit(new ApiError("Post body empty"), 400)); } catch (Exception ex) { return(processExit(new ApiError($"Server Exception: {ex.Message}", 500), 500)); } }