title: C# Azure / Postman - 405 Method not Allowed error on POST
body: <p>I followed the following tutorial and set up my azure backend .</p>
  
  <p><a href="https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/custom/" rel="nofollow noreferrer">https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/custom/</a></p>
  
  <p>I then installed postman for the first time and set : </p>
  
  <p><a href="http://apptest.azurewebsites.net/.auth/login/custom" rel="nofollow noreferrer">http://apptest.azurewebsites.net/.auth/login/custom</a></p>
  
  <p>{"username" : "adrian" , "password" : "supersecret"}</p>
  
  <p>Json (application/json)</p>
  
  <p>However , i keep getting this error :</p>
  
  <p>405 Method not Allowed</p>
  
  <pre><code>{
    "Message": "The requested resource does not support http method 'GET'."
  }
  </code></pre>
  
  <p>Backend Code : </p>
  
  <pre><code>using System;
  using System.IdentityModel.Tokens;
  using System.Linq;
  using System.Security.Claims;
  using System.Web.Http;
  using Newtonsoft.Json;
  using AppTestService.Models;
  using AppTestService.DataObjects;
  
  using Microsoft.Azure.Mobile.Server.Login;
  
  
  namespace AppTestService.Controllers
  {
      [Route(".auth/login/custom")]
      public class CustomAuthController : ApiController
      {
          private AppTestContext db;
          private string signingKey, audience, issuer;
  
          public CustomAuthController()
          {
              db = new AppTestContext();
              signingKey = Environment.GetEnvironmentVariable("WEBSITE_AUTH_SIGNING_KEY");
              var website = Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME");
              audience = $"https://{website}/";
              issuer = $"https://{website}/";
          }
  
          [System.Web.Http.HttpPost]
          public IHttpActionResult Post([FromBody] User body)
          {
              if (body == null || body.Username == null || body.Password == null ||
                  body.Username.Length == 0 || body.Password.Length == 0)
              {
                  return BadRequest();
              }
  
              if (!IsValidUser(body))
              {
                  return Unauthorized();
              }
  
              var claims = new Claim[]
              {
                  new Claim(JwtRegisteredClaimNames.Sub, body.Username)
              };
  
              JwtSecurityToken token = AppServiceLoginHandler.CreateToken(
                  claims, signingKey, audience, issuer, TimeSpan.FromDays(30));
              return Ok(new LoginResult()
              {
                  AuthenticationToken = token.RawData,
                  User = new LoginResultUser { UserId = body.Username }
              });
          }
  
          protected override void Dispose(bool disposing)
          {
              if (disposing)
              {
                  db.Dispose();
              }
              base.Dispose(disposing);
          }
  
          private bool IsValidUser(User user)
          {
              return db.Users.Count(u =&gt; u.Username.Equals(user.Username) &amp;&amp; u.Password.Equals(user.Password)) &gt; 0;
          }
  
  
      }
  
  
      public class LoginResult
      {
          [JsonProperty(PropertyName = "authenticationToken")]
          public string AuthenticationToken { get; set; }
  
          [JsonProperty(PropertyName = "user")]
          public LoginResultUser User { get; set; }
      }
  
      public class LoginResultUser
      {
          [JsonProperty(PropertyName = "userId")]
          public string UserId { get; set; }
      }
  
  
  }
  </code></pre>
  
  <p>If i add [System.Web.Http.HttpGet] on top of the function , then i get a different error. :</p>
  
  <p>415 Unsupported media type </p>
  
  <pre><code>{
    "Message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource."
  }
  </code></pre>
  
  <p>These are the headers : </p>
  
  <pre><code>Allow →POST
  Content-Length →72
  Content-Type →application/json; charset=utf-8
  Date →Sat, 28 Jan 2017 22:08:48 GMT
  Server →Microsoft-IIS/8.0
  X-Powered-By →ASP.NET
  </code></pre>