1

When trying to execute a POST request Delete(SourceInfo sourceInfo) is executed instead of Post(SourceInfo sourceInfo), if I remove Delete(SourceInfo sourceInfo) then Put(SourceInfo sourceInfo) is executed when executing a POST request. I'm pretty sure I'm doing something wrong, but I'm not able to figure out what it is.

Routes are reqistred using the IPlugin interface.

public void Register(IAppHost appHost)
{
    appHost.Routes.Add<SourceInfo>("/sources", "GET,POST,PUT");
    appHost.Routes.Add<SourceInfo>("/sources/{Name}", "GET,DELETE");
}

The service looks like this

public class SourceService : ServiceStack.ServiceInterface.Service
{    
    public SourceInfoResponse Get(SourceInfo sourceInfo)
    { ... }

    public bool Post(SourceInfo source)
    { ... }

    public bool Put(SourceInfo source)
    { ... }

    public bool Delete(SourceInfo source)
    { ... }
}

I looked at the routing description for the new api design here: https://github.com/ServiceStack/ServiceStack/wiki/New-API, but is does not look like this applies in this case.

  • What client/tool (Fiddler, ServiceStack client, ajax post, etc) are you using to make the requests? This sample https://gist.github.com/paaschpa/5405028 seems to work using Fiddler to POST to localhost/sources – paaschpa Apr 17 '13 at 15:07
  • I was using the ServiceStack client and [Postman - REST Client](https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?utm_source=chrome-ntp-icon) – Niels Henrik Hagen Apr 17 '13 at 19:52

1 Answers1

1

So I figured it out, it turns out that returning bool does not work. When I changed the return to type to object it worked right away.

like this

public class SourceService : ServiceStack.ServiceInterface.Service
{    
    public SourceInfoResponse Get(SourceInfo sourceInfo)
    { ... }

    public object Post(SourceInfo source)
    { ... }

    public object Put(SourceInfo source)
    { ... }

    public object Delete(SourceInfo source)
    { ... }
}

It also works to return a custom class.