Really simple WCF Service using JQuery keep getting error 415 unsupported media type

Posted on 2008-10-15
Last Modified: 2012-05-05
I wrote a very simple WCF service with one operation contract that returns a list of points. I then wanted to use JQuery to consume the service and get the list of points on to a web page.  I was following Rick Strahl's blog:

I keep geeting the error: 415 unsupported media type

Please could you let me know where I'm going wrong. Thanks!
using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

using System.ServiceModel.Web;


namespace Contracts


    [ServiceContract(Name = "TestService", Namespace = "Contracts")]

    public interface ITestService




            Method = "POST", 

            BodyStyle = WebMessageBodyStyle.Wrapped, 

            ResponseFormat = WebMessageFormat.Json)]

        List<Point> Search();




using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Runtime.Serialization;


namespace Contracts



    public class Point



        public double X { get; set; }


        public double Y { get; set; }




    <script type="text/javascript" src=""></script>

    <script type="text/javascript" src=""></script>


        function Run() {

            var url = "http://localhost:1436/services/testservice.svc/Search";

            var json = JSON.stringify("");



                url: url,

                data: json,

                type: "POST",

                processData: false,

                contentType: "application/json",

                timeout: 10000,

                dataType: "text",

                success: function(result) { alert("Success"); },

                error: function(result) { alert("Error"); }



Open in new window

Question by:dnoxs
1 Comment

Accepted Solution

dnoxs earned 0 total points
Comment Utility
Figured it out. I had the incorrect web config it should have looked as follows:



				<behavior name="WebBehavior">

					<webHttp />




				<behavior name="Portal.Services.TestServiceBehavior">

					<serviceMetadata httpGetEnabled="true" httpGetUrl="" />

					<serviceDebug includeExceptionDetailInFaults="false" />





			<service behaviorConfiguration="Portal.Services.TestServiceBehavior"


				<endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="Contracts.ITestService">


						<dns value="localhost" />



				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />




Open in new window


Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now