Rob Kraft's Software Development Blog

Software Development Insights

How to POST to a REST API using Fiddler

Posted by robkraft on October 24, 2012

Posting to a REST API using Fiddler is very simple, as long as you fill out all the required values correctly. I spent more than an hour figuring out the correct info for my REST API recently so I am documenting it here for my own sake, and hopefully to speed the resolution for others. The URL shown in the image is not real, so don’t expect that URL to work for yourself.

  1. Select the Composer tab in Fiddler.
  2. Select POST from the dropdown.
  3. Enter the URL of the REST API. My REST API had a .svc extension, but most REST APIs do not.
  4. In the Request Headers, include “Content-Type: text/xml”. This is the step I missed that took me so long to resolve. Your REST API may not need this, but the REST API I was working with developing on the Microsoft Stack did. You do not need to provide the values for Host or Content-Length in your Request Headers because Fiddler will populate those for you.
  5. In the Request Body, provide the XML or Json data that you are sending to the URL as part of the POST.
  6. Click on the Execute button.
  7. Check the panel on the left (not shown in the image) to see the result of your API call. For my API, the POST returned a 200 and the Response Body contained my response data.

That’s it. Good Luck!

How to POST to a REST API using Fiddler

Advertisements

7 Responses to “How to POST to a REST API using Fiddler”

  1. Wow that was unusual. I just wrote an incredibly long
    comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing
    all that over again. Anyway, just wanted to say fantastic blog!

  2. Kumar said

    I am giving all the details but not be able to get the data in the speified data contract class. It is coming null. but status code is 200. Please help.

    Thanks
    Kumar Shorav

    • robkraft said

      Is it possible that the server has no data for your request? Can you try a different request that has data?

  3. Thanks Robkraft,
    I was also exactly missing the step no. 4. Your article has helped me resolve this. Thanks you very much!

    Dhruv.

  4. Thanks For the information. I also got stuck at the beginning as well. I wanted to send a 10 digit number. Your tutorial has helped me. I am getting confirmed status now.

  5. oseroke said

    WoW.. So easy. Thanks a lot

  6. fernandohur said

    Nowadays theres easier ways of doing this, most notably using getpostman.com and of course https://apibot.co

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: