Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to use the Web Api process for Ajax in Umbraco 7 but getting a 405 Method Not Allowed error.
My js code is:
jQuery.getJSON('/Umbraco/Api/SignUp/SignUp/', { Firstname: jQuery('#Firstname').val() })
.done(function (data) {
});
And my controller is:
public class SignUpController : UmbracoApiController {
public JsonResult SignUp(string Firstname) {
Dictionary<string, object> results = new Dictionary<string, object>();
results.Add("success", true);
JsonResult res = new JsonResult();
res.Data = results;
return res;
}
Try to rename your method to GetSignUp and then request /Umbraco/Api/SignUp/GetSignUp/
Or add the [HttpGet] attribute to your method, e.g.
[HttpGet]
[HttpGet] public JsonResult SignUp(string Firstname) {
Jeavon, thanks again for saving me. I renamed the method in the controller to GetSignUp and it all worked great.
Is there something that Umbraco is doing under the covers here ? Or is it part of WebApi ?
Thanks again.
Hi Russell,
It's WebApi native here, with the prefix "Get" it allows get requests or you can decorate your method with the [HttpGet] attribute I posted above.
I remember going through exactly the same pain the first time I created a WebApi controller :-)
Jeavon
I know this is old, but I added the attribute HttpGet at that didn't fix it. Just rename with Get in front of it.
Had this exact problem too when trying to run with an api tutorial in V8. Wondered if this was governed by a setting somewhere either in IIS or Umbraco somewhere :/
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Web Api 405 Method Not Allowed
I am trying to use the Web Api process for Ajax in Umbraco 7 but getting a 405 Method Not Allowed error.
My js code is:
jQuery.getJSON('/Umbraco/Api/SignUp/SignUp/', { Firstname: jQuery('#Firstname').val() })
.done(function (data) {
});
And my controller is:
public class SignUpController : UmbracoApiController {
public JsonResult SignUp(string Firstname) {
Dictionary<string, object> results = new Dictionary<string, object>();
results.Add("success", true);
JsonResult res = new JsonResult();
res.Data = results;
return res;
}
}
Try to rename your method to GetSignUp and then request /Umbraco/Api/SignUp/GetSignUp/
Or add the
[HttpGet]
attribute to your method, e.g.Jeavon, thanks again for saving me. I renamed the method in the controller to GetSignUp and it all worked great.
Is there something that Umbraco is doing under the covers here ? Or is it part of WebApi ?
Thanks again.
Hi Russell,
It's WebApi native here, with the prefix "Get" it allows get requests or you can decorate your method with the
[HttpGet]
attribute I posted above.I remember going through exactly the same pain the first time I created a WebApi controller :-)
Jeavon
I know this is old, but I added the attribute HttpGet at that didn't fix it. Just rename with Get in front of it.
Had this exact problem too when trying to run with an api tutorial in V8. Wondered if this was governed by a setting somewhere either in IIS or Umbraco somewhere :/
is working on a reply...