Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a model class Product as:
public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Category { get; set; }
        public decimal Price { get; set; }
    }

and the API controller is ProductsController and the Post method is:
 [HttpPost]
public HttpResponseMessage PostProduct(Product item)
{
    if (item == null)
        return new HttpResponseMessage(HttpStatusCode.BadRequest);

    item = repository.Add(item);
    var response = Request.CreateResponse<Product>(HttpStatusCode.Created, item);

    string uri = Url.Link("DefaultApi", new { id = item.Id });
    response.Headers.Location = new Uri(uri);
    return response;
}

When I post JSON data from fiddler Product item, I get null value, but get method works fine.
Please anyone help me to solve this problem.
Posted
Updated 30-Nov-17 3:40am
v2
Comments
Member 13550145 30-Nov-17 10:55am    
Can you also show for date property.

1 solution

Hi,

You can solve your issue to follow these:

Request Header:

User-Agent: Fiddler
Host: localhost:4217
Content-Type: application/json; charset=utf-8

Request Body

={"Number1":"7","Number2":"7"}

Please follow following link for help by images :

http://atgsoftware.com/blog/testing-web-api-post-with-fiddler/[^]
 
Share this answer
 
Comments
[no name] 13-Sep-14 4:41am    
Thank you so much.It is working.
Sandeep Singh Shekhawat 13-Sep-14 5:57am    
Welcome dear !! I am so glad to know that it was helpful for you. I have a humble request to you that please mark it as a accepted answer and voted up.
Snesh Prajapati 13-Sep-14 5:16am    
Great...Thanks Sandeep :-)
Sandeep Singh Shekhawat 13-Sep-14 5:57am    
Welcome Ma'am !!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900