HTTP/1.1 415 Cannot process the message because the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'

后端 未结 1 1477
情歌与酒
情歌与酒 2021-01-18 06:56

trying to POST json dictionary to C# WCF, when i invoke it HTTP Response 415. Someone can tell me whats wrong with my code.

object Class

 [DataContra         


        
1条回答
  •  我在风中等你
    2021-01-18 07:28

    The endpoint for your service is not properly configured to receive JSON input. In order for the [WebInvoke] attribute to be honored, your endpoint needs to have the webHttpBinding, and it should also have an endpoint behavior of type

    One easy way to ensure that it's properly configured is to use the Factory attribute on the .svc file. Something like the example below:

    <%@ ServiceHost Language="C#" Debug="true"
                    Service="YourNamespace.YourServiceClass"
                    Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
    

    0 讨论(0)
提交回复
热议问题