0

I want to send a put request with some json strings to a server some time in the future. I want to compare the request Im sending to the requirements I have been given, but I do not have access to that server yet so I cant test if the request Im sending is looking the way it should. The only thing I found would be ToString'ing my httpWebRequest (like in this), which is not what I need.

Is there a way to read exactly what I'm sending after (or before) I send it into the void? Or alternatively, is there a way to send a request to myself and read it that way?

Edit: I cannot install foreign software on my workstation. While using a tool like Wireshark probably solves the answer for the general public, I still need a way to do this programmatically.

Edit2: Searching for the topic may have not resulted in anything, but a random topic on the right that SO suggested actually has (almost exactly) what I wanted and all it takes is copy pasting something into the web.config file. Implementing this answer puts (amongst other things) all the connections as well as their contents into the debug console.

Sven Engling
  • 39
  • 1
  • 7
  • 2
    There are probably dummy/diagnostic http endpoints, but that is a question for software recommendations stack exchange then. If you are able to just send the requests I would use fiddler or wireshark to see if the data on the wire look like I need them. – thehennyy Oct 15 '18 at 09:01

1 Answers1

0

Try using an HTTP debugging tool like Fiddler. It acts like a proxy and can let you view the request and response of HTTP requests your program sends.

Here's how to use it with HttpWebRequest: Get HTTP requests and responses made using HttpWebRequest/HttpWebResponse to show in Fiddler

If you aren't allowed to install Fiddler you could think about making your own version of Fiddler in c# to capture traffic How to create a simple proxy in C#?

Matthew Lock
  • 13,144
  • 12
  • 92
  • 130