Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

HTTP Post returns a "MethodNotAllowed" error code

Im trying to create a simple HTTP client with the following code.

Uri uri = new Uri(url);
var postData = new StringContent("Will Echo!", Encoding.UTF8);
try {
                var statusCode = await client.PostAsync(uri, postData);
                if (statusCode.IsSuccessStatusCode) {
                    var definitionResponse = await statusCode.Content.ReadAsStringAsync();
            return true;
                else {
                    Debug.WriteLine("Error Code: " + statusCode.StatusCode);
                    return false;
            catch (Exception e) {
                Debug.WriteLine("Exception thrown: " + e);
                return false;

This code will always print "Error Code: MethodNotAllowed". However this code will work with statusCode = await client.GetAsync(uri);

So what is causing this error? Is it because the url is not a secured http? Am I using the wrong port? Am I passing the wrong kind of Data?
Any help would be appreciated.


  • JarvanJarvan Member, Xamarin Team Xamurai

    Could you post the detailed error information. Or you can add breakpoints to debug to find which line codes that caused the problem.

Sign In or Register to comment.