How to test web api of MVC4.0 through Fiddler?

If you are able to monitor your client/server traffic then you can set a breakpoint on the response then fiddle with it before sending it on to the client. You can test data which is returned as result set and also check for the status code for good and bad data.

Description: Fiddler is web debugging tool which is used to test web api.
I have covered basics of fiddler for testing web api in this article.
You can use different JSON serialization and de-serialization helper classes so that you will get data Set in properties. For get method, you can use query string to pass parameters instead of DTOclass object.
Significance of terms mostly used with Fiddler:
Result : Status code
You can check Status code as OK for success. It may return status code as 'Not found' if result has not been found.
Protocol Http
Protocal used is Http.
Host : localhost You can give localhost if application is hosted in IIS of your local machine. If it has been deployed in a particular server then you have to mention that server ip.
URL : url name URL has to be mentioned which you want to test.

How to test GET method in fiddler?
For GET, use following:
http://localhost/webapinamespace/api/controllername?DTOclassobject={Data Set in properties}

How to test POST method in fiddler?
For POST, use following:
1) Select POST in dropdown box in Parsed tab.
2) Add Content-type:application/json in Request headers.
3) Put request body "DTOclassobject={Data Set in properties}"

How to test PUT and DELETE method in fiddler?
For PUT and DELETE, use following:
1) Add Content-type:application/json in Request headers.
2) Add Content-Length: 461 in Request headers.
3) Put request body "DTOclassobject={Data Set in properties}"

To implement client server architecture, you can use above mentioned information.


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: