Routes vs Operations

I am 100% positive I am missing some fairly easy concept. I have a simple service defined below

[Route("/Tenants", "POST")]
public class TenantCreate : StandardMessage, IReturn<Tenant>
{
    public Tenant Tenant { get; set; }
}

When I browse to the metadata I see an operation as TenantCreate and clicking json produces

The following routes are available for this service:
POST
/Tenants

Now I expect to be able to post a TenantCreate to /tenants like this
var service = new JsonServiceClient(“http://localhost:31001”);
service.postToService(“Tenants”, tenant, c$.Done, c$.CommonError);
But that produces a
{“ErrorCode”:“NotImplementedException”,“Message”:“The operation ‘Tenants’ does not exist for this service”

If I change to post to TenantCreate then I get the 200 I am expecting
var service = new JsonServiceClient(“http://localhost:31001”);
service.postToService(“TenantCreate”, tenant, c$.Done, c$.CommonError);

What am I missing?

If you change POST to GET are you able to navigate from browser то http://locahost:31001/Tenants without raising not implementing exception? If you still get “not implemented” are you using some custom routings in your solution?

GET is already handled by the list, this does come up by simply opening the URL (http://localhost:31001/tenants). No custom routing implemented

[Route("/Tenants", "GET")]
public class TenantList : StandardMessage, IReturn<List<Tenant>>
{        
}

Ah, I missed that you use javascript client, not the C# client. This is default behavior when that you should post DTO as first parameter (as object or dto name) not the route url. You should use .postJSON instead of .postToService to post data to URL

Not sure I understand your response, the first parameter (webmethod) is used to derive the endpoint
var requestUrl = Path.combine(this.baseSyncReplyUri, webMethod);

Fiddler shows the endpoint as /tenantcreate and routes correctly on the server even though it should fail. I am not understanding how the javascript client is controlling the server side routes. In theory I have no route for POST /tenantcreate, I have one for POST /tenants.

.postToService(dto, ...) posts to /json/reply/dto URL, not to /dto URL. If you want to post requests to your route URL, you should use $.ss.postJSON(url, …) from ss-utils

Damn it! Now I see it, I knew it was something simple! Thanks for leading me to the light :smile: