Steve Coleman
Steve Coleman

Reputation: 2027

Servicestack Gateway.Send does not work with POST

I have this service method

  public async Task Post(DeviceEndpointInsertTemp request)
        {
            //Some AYNC Code
         }

I call it like this

          var model = new DeviceEndpointInsertTemp() {DeviceNumber = deviceID, IOEndpointList = list, EventGridPostDateTime = postTime};
                var task = Gateway.SendAsync(model);
                await task; //wait for response

I get this error

{"Could not find method named Put(DeviceEndpointInsertTemp) or Any(DeviceEndpointInsertTemp) on Service IntegrationService"}

UNTIL I change the POST to ANY

public async Task ANY(DeviceEndpointInsertTemp request)
    {
        //Some AYNC Code
     }

Do you know why?

Upvotes: 1

Views: 224

Answers (1)

mythz
mythz

Reputation: 143319

This is explained in the Service Gateway Docs:

Naked Request DTO’s without annotations are sent as a POST but alternative Verbs are also supported by annotating Request DTO’s with HTTP Verb Interface Markers where Request DTO’s containing IGet, IPut, etc. are sent using the typed Verb API, e.g:

[Route("/customers/{Id}")]
public class GetCustomer : IGet, IReturn<Customer>
{
    public int Id { get; set ;}
}

So if you want to send your Service Gateway to send a PUT Request your Request DTO needs to implement the appropriate HTTP Verb Interface Marker, e.g:

public class DeviceEndpointInsertTemp : IPut, IReturn<TheResponse>
{
  //...
}

Upvotes: 1

Related Questions