c# - WebApi POST Method Not Allowed -
im trying call post method , 405 / method not allowed.
here code:
[httppost] public string postusers(string user) { return user; }
how make request
this.data.append('user', json.stringify(this.user)); var user= this.data; console.log(equipo); axios.post('/api/apiequipos', user).then((response) => { console.log('ok') }).catch(errors => { if(typeof errors.response.data === 'object'){ this.errors = _.flatten(_.toarray(errors.response.data)) }else{ this.errors = ['error']; } })
if call method thought postman run well
webapiconfig
public static class webapiconfig { public static void register(httpconfiguration config) { // web api configuration , services // web api routes config.maphttpattributeroutes(); config.routes.maphttproute( name: "defaultapi", routetemplate: "api/{controller}/{id}", defaults: new { id = routeparameter.optional } ); } }
Comments
Post a Comment