Mati Silver
Mati Silver

Reputation: 195

ServiceStack request parameters missing

I'm doing a service with ServiceStack, and I'm having a problem. I don´t see the request parameters, so, when I call the method, all parameters of the request are null. Here is the code:

public class AppHost : AppSelfHostBase
{
    public AppHost()
        : base("CallbackServer", typeof(CallbackServer).Assembly)
    {
    }

    public override void Configure(Container container)
    {
    }
}

public class CallbackServer : Service
{
    public HttpResult Post(EventoCliente request)
    {
        request.TimeReceived = DateTime.Now;
        Task.Factory.StartNew(() => Program.EventArrived(request));
        return new HttpResult(HttpStatusCode.OK,"OK");
    }
}

[Route("/turno", "Post")]
public class EventoCliente : IReturn<EventoClienteResponse>
{
    public TurnoCliente Turno;
    public string Sucursal;
    public string[] Puestos;
    public DateTime? TimeReceived;
}

public class EventoClienteResponse
{
    public ResponseStatus ResponseStatus { get; set; }
}

static void Main()
{
    var appHost = new AppHost();
    appHost.Init();
    appHost.Start("http://*:9900/NesrEmulator/");
}

So, in the browser i write: http://localhost:9900/NesrEmulator, and i can see the method EventoCliente, but i can´t see (there aren´t) the parameters for the request. Here is a screenshot of what i mean...

What i´, doing wrong? Thanks

Upvotes: 1

Views: 281

Answers (1)

mythz
mythz

Reputation: 143319

Your DTO's should use public properties not public fields so just change it to:

[Route("/turno", "Post")]
public class EventoCliente : IReturn<EventoClienteResponse>
{
    public TurnoCliente Turno { get; set; }
    public string Sucursal { get; set; }
    public string[] Puestos { get; set; }
    public DateTime? TimeReceived { get; set; }
}

Upvotes: 2

Related Questions