I'm doing a web API in c# with token, but I need to receive the parameters of postman to my method
[HttpPost, Route("api/cobro/saveEmail")]
public IHttpActionResult SaveEmailForDiscount([FromBody] string email)
{
//do something with e-mail
return Ok(email);
}
But always the email is null
This is the PostMan request
POST /api/cobro/saveEmail HTTP/1.1
Host: localhost:53107
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: 881045b2-0f08-56ac-d345-ffe2f8f87f5e
email=jose%40gm.com
This is my Startup class where is all config
using System;
using Microsoft.Owin;
using Owin;
using Microsoft.Owin.Security.OAuth;
using System.Web.Http;
using System.Net.Http.Headers;
[assembly: OwinStartup(typeof(Cobros_BackEnd.Startup))]
namespace Cobros_BackEnd
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
var MyProvider = new AuthorizationServerProvider();
OAuthAuthorizationServerOptions options = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = MyProvider
};
app.UseOAuthAuthorizationServer(options);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
HttpConfiguration config = new HttpConfiguration();
config.Formatters.JsonFormatter.SupportedMediaTypes
.Add(new MediaTypeHeaderValue("text/xml"));
//get all users
config.Routes.MapHttpRoute(
name: "Users",
routeTemplate: "api/{controller}/users",
defaults: new { id = RouteParameter.Optional }
);
WebApiConfig.Register(config);
}
}
}
I'm using other methods in GET and all work fine, but I need to use this on POST