In a previous post I talked about how to send raw JSON to a web API and consume it easily. This is a non-obvious process because ASP.NET Web API is optimized for sending and receiving arbitrary CLR object that then get serialized by the formatters in the request/response pipeline. However, sometimes you just want to have more […]
The OWIN specification defines a delegate called appFunc that allows any OWIN compatible host to work with any OWIN compatible application. This post shows you how to turn an ASP.NET Web API into an AppFunc. AppFunc is defined as , using AppFunc = Func<IDictionary<string, object>,Task>; In other words, a function that accepts an object that implements IDictionary<string,object> […]
I see questions almost weekly on StackOverflow where someone is trying to POST JSON and receive it as a string. The problem is that Web API has two modes, “serialized object” and “HTTP message”. Receiving raw JSON as a string falls between the two. Usually the question goes something like, “Why does the jsonBody parameter in the […]
I see many questions on Stackoverflow and the MSDN forums where people are having difficulty because the objects they are trying to return from there API are not being serialized as they expect. Consider you have an API action that looks like this: What are you supposed to do to debug what is going wrong […]
Ever since Microsoft’s first efforts to deliver a REST style framework in .net, back in 3.5, there has been a continuous stream of questions that has asked: how to I add a service reference to that API? How do I generate a client proxy? How do I access the WSDL for the REST service? Can […]
Rob Conery asked for some feedback on an API he has been building for Tekpub. I know that Rob asked for URLs, and URLs he shall get, but I like to get a better understanding of the relationships between my resources before I start minting URLs for my service. On a number of occasions I […]
We all have to start somewhere, and I like to start with the simplest possible thing that works. So I created a Console application and used NuGet to pull in the WebAPI.All package which contains all my dependencies.[1] Once that was done, all I need is this: If you point a browser to http://localhost:9000 you will get your first […]
It seems everyone these days wants an API for their web application. Getting a primitive Web API up and running can be deceptively simple. However, what many people don’t realize is that with the success of an API can come a variety of problems. As developers, we are used to dealing with unforeseen problems, we […]
Roy Fielding wrote this post recently on the proliferation of APIs that claim to be REST but are breaking some of the fundamental constraints of a REST style architecture. I was most struck by what Roy seems to be saying is required to document a REST Api. That is it. If you look at most API specs […]