title: Not able to download file using C# from a web api which works using postman
body: <p>I have recently started working with web api's.</p>
  <p>I need to download a file in C# project from a web api, which works fine when I hit the web api using postman's send and download option. Refer to the image, also please check the response in header's tab. This way, I am able to directly download the file to my computer.</p>
  <p><a href="https://i.stack.imgur.com/13aGY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/13aGY.png" alt="Api call using postman" /></a></p>
  <p>I want to do the same from my C# project, I found following two links which shows how to download a file from web api.</p>
  <p><a href="https://code.msdn.microsoft.com/HttpClient-Downloading-to-4cc138fd" rel="nofollow noreferrer">https://code.msdn.microsoft.com/HttpClient-Downloading-to-4cc138fd</a>
  <a href="http://blogs.msdn.com/b/henrikn/archive/2012/02/16/downloading-a-google-map-to-local-file.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/henrikn/archive/2012/02/16/downloading-a-google-map-to-local-file.aspx</a></p>
  <p>I am using the following code in C# project to get the response:</p>
  <pre><code> private static async Task FileDownloadAsync()
      {
          using (var client = new HttpClient())
          {
  
              client.DefaultRequestHeaders.Accept.Clear();
              client.DefaultRequestHeaders.Add(&quot;Accept&quot;, &quot;text/html&quot;);
              try
              {
                  // _address is exactly same which I use from postman
                  HttpResponseMessage response = await client.GetAsync(_address);
                  if (response.IsSuccessStatusCode)
                  {
                  }
                  else
                  {
                  }
              }
              catch (Exception)
              {
                  throw;
              }
          }
      }
  </code></pre>
  <p>However I am not getting the response at all (before I can start to convert the response to a file), please check the error message coming:</p>
  <p><a href="https://i.stack.imgur.com/KGGNx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KGGNx.png" alt="Error message" /></a></p>
  <p>What am I missing here, any help would be appreciated.</p>