Sitemap
Microservices for .NET Developers

A series about microservices focused on .NET development

Making Http easier with .NET Core

5 min readAug 22, 2019

--

In this article, I’m going to focus a bit about a few Http related behaviors in .NET that are needed in every microservice or API, but not easily done or found in the wild.

This article is part of a series that tries to look at challenges that faces .NET developers when building microservices.

Everything in this article is packed into one nuget package CoreX.Extensions.Http which you can add to your project and setup in your startup.cs to configure and enable these behaviors.

Better logging for bad requests (400)

Let’s start by the simplest thing, happened a thousand times, someone is calling your API and he send something wrong, missing a field or may be you updated your API and he is not aware that he should have sent a new parameter. He gets an exception but he doesn’t know why, and he asks you for help. The first thing you do is you check the logs of your API, to find this:

With no errors nor warnings, the only indication that something went wrong is the last line saying (as information):

Request finished in … 400 application/json; charset=utf-8

With only the 400 status code indicates a non success, without any hint to what went wrong, or what did the caller sent.

Although the caller got a very good Json response:

400 bad request json response for the caller

--

--

Microservices for .NET Developers
Microservices for .NET Developers

Published in Microservices for .NET Developers

A series about microservices focused on .NET development

Bishoy Labib
Bishoy Labib

Written by Bishoy Labib

Software Architect building cloud products with microservices, .NET, Node and Kubernetes

No responses yet