title: C# Web service, how to receive JSON
body: <p>I made a JSON string with jquery, and i want to send it to a C# web api controller.</p>
  
  <p>This is an example of the JSON object </p>
  
  <pre><code>{"Name":"","Type":"4","Meals":["2","3"],"Excludes":["Beef","Chicken"]}
  </code></pre>
  
  <p>I tryed to send it with a URL like this</p>
  
  <pre><code>API/Recipe/Search?json={"Name":"","Type":"4","Meals":["2","3"],"Excludes":["Beef","Chicken"]}
  </code></pre>
  
  <p>With my Controller like this:</p>
  
  <pre><code>public class RecipeController : ApiController
  {
  
      [HttpGet]
      public string Search(searchObject json)
      {
          return "Asdasd";
      }
   }
  </code></pre>
  
  <p>and like this</p>
  
  <pre><code>   public class RecipeController : ApiController
  {
  
      [HttpGet]
      public string Search(string json)
      {
          searchObject search = (searchObject)JsonConvert.DeserializeObject(json);
  
          return "Asdasd";
      }
  }
  </code></pre>
  
  <p>But in neither case the controller will pick it up. I am using MVC4. </p>
  
  <p>Here is the Jquery i am using to make the call. apiLink is the link I posted above.</p>
  
  <pre><code>$.getJSON(apiLink, function (data) {
          var items = [];
  
          $.each(data, function (key, val) {
              items.push('&lt;li id="' + key + '"&gt;' + val + '&lt;/li&gt;');
          });
  
          $('&lt;ul/&gt;', {
              'class': 'my-new-list',
              html: items.join('')
          }).appendTo('body');
      });
  </code></pre>
  
  <p>How do I get the controller to receive the JSON object?</p>
  
  <p>Thanks</p>