Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:37:15+00:00 2026-06-07T23:37:15+00:00

I made a JSON string with jquery, and i want to send it to

  • 0

I made a JSON string with jquery, and i want to send it to a C# web api controller.

This is an example of the JSON object

{"Name":"","Type":"4","Meals":["2","3"],"Excludes":["Beef","Chicken"]}

I tryed to send it with a URL like this

API/Recipe/Search?json={"Name":"","Type":"4","Meals":["2","3"],"Excludes":["Beef","Chicken"]}

With my Controller like this:

public class RecipeController : ApiController
{

    [HttpGet]
    public string Search(searchObject json)
    {
        return "Asdasd";
    }
 }

and like this

   public class RecipeController : ApiController
{

    [HttpGet]
    public string Search(string json)
    {
        searchObject search = (searchObject)JsonConvert.DeserializeObject(json);

        return "Asdasd";
    }
}

But in neither case the controller will pick it up. I am using MVC4.

Here is the Jquery i am using to make the call. apiLink is the link I posted above.

$.getJSON(apiLink, function (data) {
        var items = [];

        $.each(data, function (key, val) {
            items.push('<li id="' + key + '">' + val + '</li>');
        });

        $('<ul/>', {
            'class': 'my-new-list',
            html: items.join('')
        }).appendTo('body');
    });

How do I get the controller to receive the JSON object?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:37:18+00:00Added an answer on June 7, 2026 at 11:37 pm

    You should use POST attribute with the method, this way you will be able to post complex object to the Web API,

    You may create a class for the JSON, from json to cSharp

    public class SearchObject
    {
        public string Name { get; set; }
        public string Type { get; set; }
        public List<string> Meals { get; set; }
        public List<string> Excludes { get; set; }
    }
    

    Then in your web api, specify the method with HttpPost attribute, Web API will take care of deserialization of json in the post to your template.

    [HttpPost]
    public string Search(SearchObject json)
    {
        return "Asdasd";
    }
    

    You may try fiddler, for making a post request, in the request header specify type:

    Content-Type:application/json

    and in the request body paste your json, and Execute

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this 'web service' I made that when accessed: http://192.168.0.1/api/v1/search/?query=thequery returns a JSON
so I want to use this JQuery plugin that Stack Overflow has made available
I have made this so far. It's code that will make a json String
I am using asp.net mvc with jquery... I have made a json call to
How can I made a JSON string out of a collection in dart, as
According to Crockford's json.org , a JSON object is made up of members ,
I made a servlet which creates a Map Object: Map<String, Integer> data = new
I recently saw a jQuery example where a POST was made to Default.aspx/Test, where
I've want to create a jquery mobile form to type the SQL query from
I made this code with jquery autocomplete its just like facebook search function now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.