I'm connecting to a website with HttpWebRequest but I have the error System.Net.WebException: 'The remote server returned an error: (403) Forbidden.'
Here is my code :
var request = (HttpWebRequest)WebRequest.Create(newUri);
request.Method = "POST";
request.CookieContainer = new CookieContainer();
request.ContentType = "application/x-www-form-urlencoded";
byte[] bytes = Encoding.ASCII.GetBytes("username=" + entryLogin + "&password=" + entryPassword + "&selection=" + SELECTION + "&codeFournisseurIdentite=" + CODE_FOURNISSEUR_IDENTITE + "&execution=" + executionKey + "&_eventId=" + EVENT_ID + "&geolocation=&submit=" + SUBMIT_ACTION);
request.ContentLength = bytes.Length;
request.Credentials = CredentialCache.DefaultCredentials;
request.MaximumAutomaticRedirections = 3;
request.AllowAutoRedirect = true;
await Task.Delay(30000);
using (HttpWebResponse webSiteresponse = (HttpWebResponse)request.GetResponse())
{
foreach (Cookie cook in webSiteresponse.Cookies)
{
cookieContainer.Add(cook);
}
}
I didn't understand what is wrong... Can someone help me ?
Aucun commentaire:
Enregistrer un commentaire