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 8174353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:26:06+00:00 2026-06-06T22:26:06+00:00

AJAX Call $.ajax({ url: ‘/api/Inventory’, cache: false, type: ‘POST’, data: json, contentType: ‘application/json, charset=utf-8’,

  • 0

AJAX Call

$.ajax({
    url: '/api/Inventory',
    cache: false,
    type: 'POST',
    data: json,
    contentType: 'application/json, charset=utf-8',
    statusCode: {
        201: function (data) {
            console.log(data);
            viewModel.items.push(data);
        }
    }
});

Sent Data (json) / Request Payload

{"Id":0,"Upc":"3456789012","Quantity":"200","Category":"Vodka","TransactionType":"Audit","MetaData":"ABSOLUT 750ml"} 

Response Error

No MediaTypeFormatter is available to read an object of type
‘InventoryItem’ from content with media type ”undefined”.”

Routed POST method

public HttpResponseMessage PostItem(InventoryItem item)

All properties in the JSON string are present in the InventoryItem model.

A similar question regarding complex types suggested upgrading from Beta to RC to fix a model binding change, which I have done.

If the question isn’t obvious, how do I rectify this error? If I add the the [FromUri] attribute to the Routed POST method, then the AJAX call is routed properly, but with an empty InventoryItem. If you need any other information, please let me know.

  • 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-06T22:26:08+00:00Added an answer on June 6, 2026 at 10:26 pm
    contentType: 'application/json, charset=utf-8',
    

    should be:

    contentType: 'application/json; charset=utf-8',
    

    Notice the usage of ; instead of , which is the correct separator between the content type and the charset. Also if you follow standard RESTful conventions your controller action should be called Post and not PostItem as you have shown:

    public HttpResponseMessage Post(InventoryItem item)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my ajax call: $.ajax({ url: 'url-to-json', type: 'POST', dataType: 'json', cache: 'false', data:
I am making this ajax call: $.ajax({ url: /test/whatever, type: 'post', contentType: 'application/json' data:
i have an ajax call $.ajax({ url: '<%=Url.Action(SaveDetails,Survey) %>', dataType: 'JSON', cache: false, data:
Here is the ajax call: $.ajax({ url: /TheControllerName/MyMethod, type: GET, contentType: application/json, dataType: 'json',
I am making an ajax call $.ajax({ url: urpath, type: 'POST', dataType: 'json', data:
I have the following restful api ajax call: $.ajax({ type: POST, url: https://website.com/a/login, data:
I do an ajax call: $.ajax({ url: '/foo/getData', dataType: 'json', async: false, success: function(data){
I have the following code: $.ajax({ type: POST, url: url, data: sendable, dataType: json,
I have this ajax call at the moment: $.ajax({ url: misc/sendPM.php, type: POST, data:
I have a jQuery AJAX call with type:'GET' like this: $.ajax({type:'GET',url:'/createUser',data:userId=12345&userName=test, success:function(data){ alert('successful'); }

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.