Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF REST Service not accepting JSON in .Net 4
    primarykey
    data
    text
    <p>I've been trying out the StandardEndpoints that were introduced as part of .Net 4 and I'm getting the most peculiar of errors.</p> <p>My code</p> <pre><code>[ServiceContract] public interface IAuthenticator { [OperationContract] [WebInvoke(UriTemplate = "AuthenticateUser", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)] AuthPacket AuthenticateUser(string Username, string Password, string DeviceId); } </code></pre> <p>My web.config</p> <p> </p> <pre><code>&lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;/system.web&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"&gt; &lt;/modules&gt; &lt;/system.webServer&gt; &lt;system.serviceModel&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt; &lt;standardEndpoints&gt; &lt;webHttpEndpoint&gt; &lt;!-- Configure the WCF REST service base address via the global.asax.cs file and the default endpoint via the attributes on the &lt;standardEndpoint&gt; element below --&gt; &lt;standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/&gt; &lt;/webHttpEndpoint&gt; &lt;/standardEndpoints&gt; &lt;/system.serviceModel&gt; </code></pre> <p></p> <p>The exception that is driving me crazy!</p> <pre><code>415 Cannot process the message because the content type 'application/json' was not the expected type 'text/xml; charset=utf-8'. </code></pre> <p>I can make the problem going away by going back to the .Net 3.5 standard of declaring each service, but, unless I am mistaken, one of the major upgrades in WCF with .Net 4 was it's ability to handle stuff like this. Am I doing something wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload