Answered by:
How do I test Put Method

Question
-
User-400158872 posted
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."}
Friday, August 28, 2015 2:18 PM
Answers
-
User-782957977 posted
Chrome Advanced rest client is a good tool to test rest service. Looks like id is missing in the url. Please do following steps
1) Enter url as http://localhost:34133/api/product/1
2) Add product in JSON format in rest client payload (Request body)
3) Set "application/json" as content type
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, August 28, 2015 10:41 PM -
User-84896714 posted
Hi sumittuladhar,
Thank you for your post. According to your description, I suggest you use Fiddler to test put method. You could download fillder from below link.
http://www.telerik.com/fiddlerFiddler provide Composer function, it allow us to input http method and url to initiate a request.
http://docs.telerik.com/fiddler/Generate-Traffic/Tasks/CreateNewRequestBest Regards,
Wang Li- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 31, 2015 9:48 PM
All replies
-
User-782957977 posted
Chrome Advanced rest client is a good tool to test rest service. Looks like id is missing in the url. Please do following steps
1) Enter url as http://localhost:34133/api/product/1
2) Add product in JSON format in rest client payload (Request body)
3) Set "application/json" as content type
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, August 28, 2015 10:41 PM -
User-84896714 posted
Hi sumittuladhar,
Thank you for your post. According to your description, I suggest you use Fiddler to test put method. You could download fillder from below link.
http://www.telerik.com/fiddlerFiddler provide Composer function, it allow us to input http method and url to initiate a request.
http://docs.telerik.com/fiddler/Generate-Traffic/Tasks/CreateNewRequestBest Regards,
Wang Li- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, August 31, 2015 9:48 PM