title: Azure App Service Error 405 - The request could not be completed. (Method Not Allowed)
body: <p>I'm working with Azure App Service .NET backend with a Xamarin.iOS app. I am able to successfully register a new user and I can see the user's details in the database. I have a custom ApiController, which handles the registration and the I'm able to save the details with a successful POST call.</p>
  
  <p>However, when I try to log into the app, I get the following error:</p>
  
  <pre><code>{Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: The request could not be completed.  (Method Not Allowed) 
  </code></pre>
  
  <p>Below is my code:</p>
  
  <p><strong>The RegistrationController in the backend which successfully makes a POST call</strong></p>
  
  <pre><code>[MobileAppController]
  [RoutePrefix("api/register")]
  [AllowAnonymous]
  public class RegisterController : ApiController
  {
  
       [HttpPost]
      [Route("newuser")]
      public HttpResponseMessage NewUser(RegistrationRequest request)
      {
          // Registration code in here
  
      }
  
  }
  </code></pre>
  
  <p>This is how I call this function on the client side:</p>
  
  <pre><code>public async Task&lt;Result&lt;UserProfile&gt;&gt; RegisterUser(RegistrationWrapper registrationrequest)
      {
          try
          {
              var registrationRequest = new JObject();
              registrationRequest.Add("username", registrationrequest.username);
              registrationRequest.Add("password", registrationrequest.password);
              registrationRequest.Add("email", registrationrequest.email);
              registrationRequest.Add("phone", registrationrequest.phone);
              registrationRequest.Add("firstname", registrationrequest.firstname);
              registrationRequest.Add("lastname", registrationrequest.lastname);
  
              var result = await client.InvokeApiAsync("register/newuser", registrationRequest);
  
  
       // Handle result here
  
          }
          catch (Exception ex)
          {
              return Result&lt;UserProfile&gt;.Failure(ex.Message + ex.StackTrace + ex.InnerException);
          }
  
      } 
  </code></pre>
  
  <p><strong>Custom AuthController which handles the login</strong> </p>
  
  <p>This POST call fails with the error described above.</p>
  
  <pre><code> [MobileAppController]
  [RoutePrefix("api/auth")]
  public class AuthController : ApiController
  {
      public HttpResponseMessage Post(AuthenticationRequest credentials)
      {
          try
          {
                //Authentication code goes here
  
            catch (Exception e)
          {
              Console.WriteLine("Ërror :" + e.Message);
              Console.WriteLine(e.StackTrace);
              return Request.CreateResponse(HttpStatusCode.InternalServerError, new
              {
                  Stacktrace = e.StackTrace,
                  ErrorMessage = e.Message,
                  Credentials = credentials
              });
          }
  
  
      }
  </code></pre>
  
  <p>How I invoke this function from the client side</p>
  
  <pre><code> async Task&lt;Result&lt;Account&gt;&gt; Login(string username, string password)
      {
          try
          {
              var credentials = new JObject();
              credentials.Add("username", username);
              credentials.Add("password", password);
              var result = await client.InvokeApiAsync("auth", credentials);
  
  
            //Handle result here
  
          }
          catch (Exception ex)
          {
              return Result&lt;Account&gt;.Failure(ex, ex.Message + ex.StackTrace);
          }
  
      }
  
  }
  </code></pre>
  
  <p>I'm not sure why it's failing during the log in. Any ideas?</p>