Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How do I test Put Method

$
0
0

I have following code for Put method for my ProductController.

public HttpResponseMessage Put(int id, Product product)
        {
            if (ModelState.IsValid && id == product.Id)
            {
                var result = _repository.Update(id, product);
                if (result == false)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }
                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }

How can i test this method in the browser using fiddler or any other developer tools for chrome. 

I tried using Put method using Advanced Client Rest but got the error.

{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:34133/api/product/'.","MessageDetail":"No action was found on the controller 'Product' that matches the request."}


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>