How to send a GET request exactly like I have it in fiddler?












0















So I am trying to build a program in C#. I want to send a really specific request. Exactly as I receive it in fiddler. Right now I am using fiddlers composer feature to send the request. Here is how I get the request in fiddler



How can I send it exactly as shown on the picture but in a C# console application?



Basically looking for a way to get a request in fiddler and implement it directly in to my code in the format that fiddler gives it to me.(In fiddler I can save the request in .txt format. If I could use that same .txt format to send the request then it would be really helpful)










share|improve this question



























    0















    So I am trying to build a program in C#. I want to send a really specific request. Exactly as I receive it in fiddler. Right now I am using fiddlers composer feature to send the request. Here is how I get the request in fiddler



    How can I send it exactly as shown on the picture but in a C# console application?



    Basically looking for a way to get a request in fiddler and implement it directly in to my code in the format that fiddler gives it to me.(In fiddler I can save the request in .txt format. If I could use that same .txt format to send the request then it would be really helpful)










    share|improve this question

























      0












      0








      0








      So I am trying to build a program in C#. I want to send a really specific request. Exactly as I receive it in fiddler. Right now I am using fiddlers composer feature to send the request. Here is how I get the request in fiddler



      How can I send it exactly as shown on the picture but in a C# console application?



      Basically looking for a way to get a request in fiddler and implement it directly in to my code in the format that fiddler gives it to me.(In fiddler I can save the request in .txt format. If I could use that same .txt format to send the request then it would be really helpful)










      share|improve this question














      So I am trying to build a program in C#. I want to send a really specific request. Exactly as I receive it in fiddler. Right now I am using fiddlers composer feature to send the request. Here is how I get the request in fiddler



      How can I send it exactly as shown on the picture but in a C# console application?



      Basically looking for a way to get a request in fiddler and implement it directly in to my code in the format that fiddler gives it to me.(In fiddler I can save the request in .txt format. If I could use that same .txt format to send the request then it would be really helpful)







      c# request httpwebrequest webrequest http-get






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 15:32









      ArcArc

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You need to create HttpClient instance and set the headers shown in the fiddler to the same values. Hope this helps. Your URL was HTTPS hence you will need to set for certificate validation OR you will have to set avoid certificate errors on the call.



          // Create a client
          HttpClient httpClient = new HttpClient();

          // Add a new Request Message
          HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Put, "https://yoursitehere/");

          // Add our custom headers
          requestMessage.Headers.Add("User-Agent", "User-Agent-Here");
          requestMessage.Headers.Add("Connection", "MIME-Type-Here");
          requestMessage.Headers.Add("Cache-Control", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Language", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Encoding", "value-from-fiddler");
          requestMessage.Headers.Add("Accept", "value-from-fiddler");
          requestMessage.Headers.Add("User-Agent", "value-from-fiddler");

          // Send the request to the server
          HttpResponseMessage response = await httpClient.SendAsync(requestMessage);

          // Just as an example I'm turning the response into a string here
          string responseAsString = await response.Content.ReadAsStringAsync();





          share|improve this answer
























          • User-Agent, Connection and Accept are restricted. How do I go about to change them?

            – Arc
            Jan 2 at 15:54











          • Found the answer: stackoverflow.com/a/36038562/10765219

            – Arc
            Jan 2 at 16:01











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009042%2fhow-to-send-a-get-request-exactly-like-i-have-it-in-fiddler%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You need to create HttpClient instance and set the headers shown in the fiddler to the same values. Hope this helps. Your URL was HTTPS hence you will need to set for certificate validation OR you will have to set avoid certificate errors on the call.



          // Create a client
          HttpClient httpClient = new HttpClient();

          // Add a new Request Message
          HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Put, "https://yoursitehere/");

          // Add our custom headers
          requestMessage.Headers.Add("User-Agent", "User-Agent-Here");
          requestMessage.Headers.Add("Connection", "MIME-Type-Here");
          requestMessage.Headers.Add("Cache-Control", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Language", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Encoding", "value-from-fiddler");
          requestMessage.Headers.Add("Accept", "value-from-fiddler");
          requestMessage.Headers.Add("User-Agent", "value-from-fiddler");

          // Send the request to the server
          HttpResponseMessage response = await httpClient.SendAsync(requestMessage);

          // Just as an example I'm turning the response into a string here
          string responseAsString = await response.Content.ReadAsStringAsync();





          share|improve this answer
























          • User-Agent, Connection and Accept are restricted. How do I go about to change them?

            – Arc
            Jan 2 at 15:54











          • Found the answer: stackoverflow.com/a/36038562/10765219

            – Arc
            Jan 2 at 16:01
















          0














          You need to create HttpClient instance and set the headers shown in the fiddler to the same values. Hope this helps. Your URL was HTTPS hence you will need to set for certificate validation OR you will have to set avoid certificate errors on the call.



          // Create a client
          HttpClient httpClient = new HttpClient();

          // Add a new Request Message
          HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Put, "https://yoursitehere/");

          // Add our custom headers
          requestMessage.Headers.Add("User-Agent", "User-Agent-Here");
          requestMessage.Headers.Add("Connection", "MIME-Type-Here");
          requestMessage.Headers.Add("Cache-Control", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Language", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Encoding", "value-from-fiddler");
          requestMessage.Headers.Add("Accept", "value-from-fiddler");
          requestMessage.Headers.Add("User-Agent", "value-from-fiddler");

          // Send the request to the server
          HttpResponseMessage response = await httpClient.SendAsync(requestMessage);

          // Just as an example I'm turning the response into a string here
          string responseAsString = await response.Content.ReadAsStringAsync();





          share|improve this answer
























          • User-Agent, Connection and Accept are restricted. How do I go about to change them?

            – Arc
            Jan 2 at 15:54











          • Found the answer: stackoverflow.com/a/36038562/10765219

            – Arc
            Jan 2 at 16:01














          0












          0








          0







          You need to create HttpClient instance and set the headers shown in the fiddler to the same values. Hope this helps. Your URL was HTTPS hence you will need to set for certificate validation OR you will have to set avoid certificate errors on the call.



          // Create a client
          HttpClient httpClient = new HttpClient();

          // Add a new Request Message
          HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Put, "https://yoursitehere/");

          // Add our custom headers
          requestMessage.Headers.Add("User-Agent", "User-Agent-Here");
          requestMessage.Headers.Add("Connection", "MIME-Type-Here");
          requestMessage.Headers.Add("Cache-Control", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Language", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Encoding", "value-from-fiddler");
          requestMessage.Headers.Add("Accept", "value-from-fiddler");
          requestMessage.Headers.Add("User-Agent", "value-from-fiddler");

          // Send the request to the server
          HttpResponseMessage response = await httpClient.SendAsync(requestMessage);

          // Just as an example I'm turning the response into a string here
          string responseAsString = await response.Content.ReadAsStringAsync();





          share|improve this answer













          You need to create HttpClient instance and set the headers shown in the fiddler to the same values. Hope this helps. Your URL was HTTPS hence you will need to set for certificate validation OR you will have to set avoid certificate errors on the call.



          // Create a client
          HttpClient httpClient = new HttpClient();

          // Add a new Request Message
          HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Put, "https://yoursitehere/");

          // Add our custom headers
          requestMessage.Headers.Add("User-Agent", "User-Agent-Here");
          requestMessage.Headers.Add("Connection", "MIME-Type-Here");
          requestMessage.Headers.Add("Cache-Control", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Language", "value-from-fiddler");
          requestMessage.Headers.Add("Accept-Encoding", "value-from-fiddler");
          requestMessage.Headers.Add("Accept", "value-from-fiddler");
          requestMessage.Headers.Add("User-Agent", "value-from-fiddler");

          // Send the request to the server
          HttpResponseMessage response = await httpClient.SendAsync(requestMessage);

          // Just as an example I'm turning the response into a string here
          string responseAsString = await response.Content.ReadAsStringAsync();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 15:40









          Manoj ChoudhariManoj Choudhari

          2,3481721




          2,3481721













          • User-Agent, Connection and Accept are restricted. How do I go about to change them?

            – Arc
            Jan 2 at 15:54











          • Found the answer: stackoverflow.com/a/36038562/10765219

            – Arc
            Jan 2 at 16:01



















          • User-Agent, Connection and Accept are restricted. How do I go about to change them?

            – Arc
            Jan 2 at 15:54











          • Found the answer: stackoverflow.com/a/36038562/10765219

            – Arc
            Jan 2 at 16:01

















          User-Agent, Connection and Accept are restricted. How do I go about to change them?

          – Arc
          Jan 2 at 15:54





          User-Agent, Connection and Accept are restricted. How do I go about to change them?

          – Arc
          Jan 2 at 15:54













          Found the answer: stackoverflow.com/a/36038562/10765219

          – Arc
          Jan 2 at 16:01





          Found the answer: stackoverflow.com/a/36038562/10765219

          – Arc
          Jan 2 at 16:01




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54009042%2fhow-to-send-a-get-request-exactly-like-i-have-it-in-fiddler%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith