Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Friday, 12 January 2018

C# UWA StatusCode: 415, ReasonPhrase: 'Unsupported Media Type'

Error: StatusCode: 415, ReasonPhrase: 'Unsupported Media Type'

Root cause:

        var jsonContent = JsonConvert.SerializeObject(InputContent);
       StringContent content = new StringContent(jsonContent );

       var result = await client.PostAsync("http://localhost/MyAPI/api/login", content);

content is not having right media type

Solution:

format content to right media type

  var jsonContent = JsonConvert.SerializeObject(InputContent);
       StringContent content = new StringContent(jsonContent ,Encoding.UTF8, "application/json"); 

       var result = await client.PostAsync("http://localhost/MyAPI/api/login", content);



Monday, 10 March 2014

Difference Between API And Web Service

Difference Between API And Web Service
1. All Web services are APIs but all APIs are not Web services.
2. Web services might not perform all the operations that an API would perform.
3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication whereas API may use any style for communication.
4. A Web service always needs a network for its operation whereas an API doesn’t need a network for its operation.
5. An API facilitates interfacing directly with an application whereas a Web service interacts with two machines over a network.
6.web service is like advanced Urls and API is Programmed Interface.
7.API contains classes and Interfaces just like a program.
8.A web service is a form of API (Application Programming Interface).
9.An API is used by a computer programmer to establish a link between software applications. This interface can take several forms, a web service is just one of these.
10.There are several types of web service. SOAP (Simple Object Access Protocol) is one of the most common. The API takes the form of a service description (WSDL) which is used to automatically generate the program code which makes the connection.