I had a number of integration test passing using JsonServiceClient and swapped the client to the JsonHttpClient and a couple failed.
The message coming back was “Specified method is not supported.”
Here’s the tests that failed (failed on the Post):
IServiceClient GetClient()
{
return new JsonHttpClient(ListeningOn);
}
[TestMethod]
public void GetDeviceScan_Test()
{
var client = GetClient();
client.Post(new DeviceScanRequest { DeviceId = 0});
Thread.Sleep(1000);
var status = client.Get<DeviceScanStatusResponse>(new DeviceScanStatus() { DeviceId = 0});
Assert.IsTrue(status.Enable);
Assert.IsTrue(status.Status.Length > 5);
}
My DTO’s
[Route("/bacnet/devicescan/{deviceId}",HttpMethods.Post)]
public class DeviceScanRequest : IHasVersion
{
public int DeviceId { get; set; }
public int Version { get; set; }
}
public class DeviceScanResponse : IHasResponseStatus
{
public ResponseStatus ResponseStatus { get; set; }
}
What fixed it was I included the IReturn in the DTO. (Also worked if I used client.Post<DeviceScanResponse>
)
[Route("/bacnet/devicescan/{deviceId}",HttpMethods.Post)]
public class DeviceScanRequest : IHasVersion, IReturn<DeviceScanResponse>
{
public int DeviceId { get; set; }
public int Version { get; set; }
}
I thought the IReturn types were optional on DTO’s, but looks like it isn’t on the new JsonHttpClient.