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

  • Home
  • SEARCH
  • 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 8533559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:59:18+00:00 2026-06-11T09:59:18+00:00

I have this code: $.ajax({ type: POST, url: /api/slide, cache: false, contentType: application/json; charset=utf-8,

  • 0

I have this code:

   $.ajax({


        type: "POST",
        url: "/api/slide",
        cache: false,
        contentType: "application/json; charset=utf-8",
        data: '{"Title":"fghfdhgfdgfd"}',
        dataType: "json",

An this is my controler:

public class SlideController : ApiController
{

    // POST /api/Slide
    public void Post(string Title)
    {
    }

When I run the code and call the /api/Slide, the [Title] has no data and is null.

How do I post JSON to the API controller?

POST http://127.0.0.2:81/api/slide HTTP/1.1
Host: 127.0.0.2:81
Connection: keep-alive
Content-Length: 18
Origin: http://127.0.0.2:81
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
Content-Type: application/json; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://127.0.0.2:81/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Title=fghfdhgfdgfd
  • 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-11T09:59:19+00:00Added an answer on June 11, 2026 at 9:59 am

    Define a view model:

    public class SlideViewModel
    {
        public string Title { get; set; }
    }
    

    then have your controller action take this view model as argument:

    public class SlideController : ApiController
    {
        // POST /api/Slide
        public void Post(SlideViewModel model)
        {
            ...
        }
    }
    

    finally invoke the action:

    $.ajax({
        type: 'POST',
        url: '/api/slide',
        cache: false,
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify({ title: "fghfdhgfdgfd" }),
        success: function() {
            ...    
        }
    });
    

    The reason for that is that simple types such as strings are bound from the URI. I also invite you to read the following article about model binding in the Web API.

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

Sidebar

Related Questions

I have this code: $.ajax({ type: POST, data: JSON.stringify(formData), dataType: json, url: http://www.test.com/users/ +
I have this code that works well: {livre:empty_name} $.ajax({ url: sent.php, type: post, dataType:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
i have this code for sending data var test={imagename:apple.jpg,x:13,y:33}; $.ajax({ type: POST, url: some.php,
I have this code in jquery: $.ajax({ type: POST, url: tosql.php, data: {textnode: textnode},
i have this little code to post to my server $.ajax({ type: 'POST', url:
I have this code : $.ajax({ type: POST, url: tosql.php, data: { content, content
I have this code which works. $.ajax({ type: GET, url: includes/process.php, data: captcha= +
In my document I have this script: $.ajax({ type:POST,url:ajax.php,data:data, success: function() { //onsuccess },
I have the following restful api ajax call: $.ajax({ type: POST, url: https://website.com/a/login, data:

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.