Close

Document REST service with Mermaid

For documentation of a REST service you can use a Javascript library called Mermaid (https://mermaidjs.github.io/). From the GitHub page, Mermaid is recommended as follows: Ever wanted to simplify documentation and avoid heavy tools like Visio when explaining your code? This is why mermaid was born, a simple markdown-like script language for generating charts from text…

Authorizing REST service using an API key

It’s quite common to use an API key as a means to authorize a REST service. The first step is to add a message handler in the Application_Start event of Global.asax: protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configuration.MessageHandlers.Add(new AuthorizationHeaderHandler()); } The AuthorizationHandler.cs file is contained in the App_Start folder. On initialization the apiKey and apiKeyEnabled setting…

Playing around with REST APIs

Based on the following video: https://www.youtube.com/watch?v=7YcW25PHnAA Just try the following: https:/graph.facebook.com/youtube You get JSON back, which contains like the number of likes Now use parameters: https:/graph.facebook.com/youtube?fields=id,name,likes Only id, name and likes are returned Now let’s call Google maps to get back the longitude and latitide geo location: maps.googleapis.com/maps/api/geocode/json Server is: maps.googleapis.com Resources are: maps, api,…

REST service with basic authentication

Basic Authentication for your service does not allow you to override the IIS behavior and intercept those credentials using a custom username/password validator. This is because IIS is handling the authentication prior to the WCF service being called. To summarize: • IIS does the authentication before WCF receives the request. • By default IIS uses…

System.ServiceModel.Channels.Message

When you call a REST service, behind the scenes the network message is wrapped in an object that the rest of the WCF infrastructure can understand. This object is an instance of System.ServiceModel.Channels.Message. Although Message is modeled somewhat after a SOAP message pattern, with a header and a body, it isn’t necessarily tied to the…