I am checking out the IRestGateway, and I have it working for GET and DELETE endpoints. However, when trying a POST, I get a null reference thrown on the line json.FromJson(), which seems to be because the response T is unknown.
The Send command of the POST is working, as I can see the newly created data in the external system, so the issue is that I am not mapping to Json response to the ReponseDto T.
Any ideas, what I am doing wrong?
namespace My.ServiceModel.Types
public class TradeInformation
{
public int Id { get; set; } = 0;
public string Reference { get; set; } = "";
public string Status { get; set; } = "";
}
namespace My.ServiceModel
[Route("/trade", "POST")]
public class CreateTrade : IPost, IReturn<CreateTradeResponse>
{
public string Reference { get; set; }
public string Status { get; set; }
}
public class CreateTradeResponse : TradeInformation
{
}
namespace My.ServiceInterface
public CreateTradeResponse Post(CreateTrade request)
{
return gateway.Send(request);
}
public class ExternalGateway : IRestGateway
public T Send<T>(IReturn<T> request, string method, bool sendRequestBody = true, string idempotencyKey = null)
{
using (new ConfigScope())
{
var relativeUrl = request.ToUrl(method);
var body = sendRequestBody ? request.GetDto().ToJson() : null;
var json = Send(relativeUrl, method, body, idempotencyKey);
var response = json.FromJson<T>(); // T seems to be unnown
return response;
}
}