Posts

Showing posts from December, 2016

Azure API: Why does my API in the API Management Developer Portal not have a subscription key?

Image
I encountered this problem recently when trying to add an API to my API Management. I followed all the steps but my API execution complained that the subscription key was missing. The reason for the error is that my API was not associated to a Product. To fix this, 1. Open the Publisher Portal from 'Overview' option in the API Management blade 2. Navigate to the 'Products' tab and assign the API to a product 3. Now navigate to the Developer Portal and subscription key value is now set in the request header.

How can I document my API with Swagger?

Image
Swagger has provided a very simple way to document your APIs. I created a simple OOTB Web Application with the Web API template. To create the swagger output: 1. Add the SwashBuckle nuget package 2. Publish the API and navigate to <API URL> /swagger/docs/v1 . This will create the swagger json 3. Save the file in a swagger.json file in the solution. 4. Open the file with the  http://editor.swagger.io/#/ to retrieve the documentation.

C#: How do I create a comma separated list from an object?

        public static string CreateCSVFromObject(object obj)         {             if (obj == null)             {                 throw new ArgumentNullException("obj", "Value can not be null or Nothing!");             }             StringBuilder sb = new StringBuilder();             Type t = obj.GetType();             PropertyInfo[] pi = t.GetProperties();             for (int index = 0; index < pi.Length; index++)             {                 sb.Append(pi[index].GetValue(obj, null));                 if (index < pi.Length - 1)        ...