title: forbidden:403 error while using wcf restful service
body: <p>I am trying to consume wcf restful service. The code is as follows:</p>
  
  <pre><code>private static string SendRequest(string uri, string method, string contentType, string body)
          {
              string responseBody = null;
  
              HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
              req.Method = method;
              if (!String.IsNullOrEmpty(contentType))
              {
                  req.ContentType = contentType;
              }
              if (body != null)
              {
                  byte[] bodyBytes = Encoding.UTF8.GetBytes(body);
                  req.GetRequestStream().Write(bodyBytes, 0, bodyBytes.Length);
                  req.GetRequestStream().Close();
              }
              req.Accept = "*/*"; 
              HttpWebResponse resp;
  
              resp = (HttpWebResponse)req.GetResponse();
  
              return responseBody;
          }
  </code></pre>
  
  <p>Now the issue is, sometimes it works fine and sometimes i get the error</p>
  
  <pre><code>"the remote server returned an error 403 forbidden."
  </code></pre>
  
  <p>I cannot figure out why it fails. Any idea???</p>