Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Forbidden HTTP status code when sending HTTP Post

$
0
0

I want to send an HTTP Post request to a website in order to log in and get some data from another page which requires an authorized user.

So when I run the following code I get a 403 forbidden status.

     static async void GetHtmlAnswer()
            {
                var values = new Dictionary<string, string>
                {
                   { "userName", "myUsername" },
                   { "pwd", "myPassword" }
                };

                var content = new FormUrlEncodedContent(values);

                var response = await client.PostAsync("fromURL", content);

                var responseString = await response.Content.ReadAsStringAsync();

                var answer = await client.GetStringAsync("secondPageURL");

                Console.WriteLine(responseString);
            }

The variable response is from the first page that contains the login form and the variable answer is desired html code that requires login.

Note: My credentials are right and I can login properly.

Any ideas what should I do?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>