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

后端 未结 3 2070
别跟我提以往
别跟我提以往 2021-01-01 18:03

I am get the above response when calling a WCF service via ajax json. My calling code is:



        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 18:56

    For anyone who lands here by searching: 'content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'

    A similar error was caused in my case by building and running a service without proper attributes. I got this error message when I tried to update the service reference in my client application. It was resolved when I correctly applied '[DataContract]' and '[DataMember]' attributes to my custom classes.

    Edit: This would most likely be applicable if your service was set up and working and then it broke after you edited it.

提交回复
热议问题