Posts

Showing posts from 2020

How to receive JSON object in POST and GET using web api

  ASP.NET Web API   is a great tool for building HTTP services with ASP.NET. It makes many things HTTP that used to be ill defined in .NET easy and allows you to build a variety of services very easily. Like other complex abstraction frameworks it makes complex scenarios super easy, while some very simple and common operations are not quite as straight forward or as transparent as they should be.   Capturing the raw Request Body But things are not so easy and transparent when you want to pass simple parameters like strings, numbers, dates etc. Because Web API is based on a host of conventions, some things that should be easy, such as easily picking up the raw content of a POST or PUT operation and capturing it, aren't quite so transparent as the automatic type mapping shown above. One thing you might expect to be able to easily do, is to pick up the entire content body and map it to a parameter like this: [ HttpPost ]         public string PostRawBuffer( strin