title: The remote server returned an error: (401) Unauthorized c#
body: <p>i am doing one project which will connect to some broker.. it will send a request and get response from server. I need to handle 2 request. one is authentication request and second is approve request. My authentication request is working fine but my approve request is failing with &quot;unauthorized&quot; error. Can someone please guide me whats going wrong. There API says we need to send all data in header with GET as method.Thats the reason I have added as custom headers. Help will be highly appreciated.</p>
  <pre><code>HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(www.someurl.com);             
  webrequest.Headers.Add(&quot;Machine&quot;, Dns.GetHostName());
  webrequest.Headers.Add(&quot;Authorization&quot;, &quot;bearer&quot; + LoginToken); //This token I get during authentication. i also tried removing the word &quot;bearer&quot; still it is failure.
  webrequest.Headers.Add(&quot;username&quot;, requestList[0].userid);              
  webrequest.Headers.Add(&quot;messageType&quot;, &quot;SS&quot;);
  webrequest.Headers.Add(&quot;customerUniqueTransactionId&quot;, requestList[0].locateId);
  webrequest.Headers.Add(&quot;scageUserId&quot;, requestList[0].userid);
  webrequest.Headers.Add(&quot;accountNumber&quot;, requestList[0].account);
  webrequest.Headers.Add(&quot;security&quot;, requestList[0].symbol);
  webrequest.Headers.Add(&quot;currencyId&quot;, &quot;024&quot;);
  webrequest.Headers.Add(&quot;orderQuantity&quot;, requestList[0].shares.ToString());
  webrequest.Headers.Add(&quot;tifInd&quot;, &quot;IOC&quot;);
  webrequest.Headers.Add(&quot;repCodeId&quot;, &quot;1980&quot;);
  webrequest.Headers.Add(&quot;overrideException&quot;, &quot;N&quot;);
  webrequest.Accept = &quot;application/json&quot;;
  webrequest.ContentType = &quot;application/json&quot;;
  **webrequest.Method = &quot;GET&quot;;**
  HttpWebResponse resp = (HttpWebResponse)webrequest.GetResponse();
  Stream oRespStrm = resp.GetResponseStream();
  using (StreamReader oStrmRead = new StreamReader(oRespStrm))
  {
     responseFromServer = oStrmRead.ReadToEnd();                 
  }
  </code></pre>