In the demos folder there isn't the complete code of the example given in the tutorial.
By I type it in and recreate it manually. First using the POST command.
I use the Delphi REST debugger to send:
POST http://localhost:2002/nethd/myservice/sum?a=5&b=8 HTTP/1.1
With custom body of:
POST /nethd/myService/Sum HTTP/1.1
Host: localhost:2002
{
"a": 5,
"b": 8
}
I get the following:
500 internal server error
{
"error":
{
"code":"TJsonReader.EObjectOrArrayExpected",
"message":"Object or array expected as top-level value"
}
}
So I try it using a GET instead and adding in the [HTTPGet] lines.
type
[ServiceImplementation]
TMyService = class(TInterfacedObject, IMyService)
private
[HttpGet]
function Sum(A, B: double): double;
// function FindOverduePayments(CustomerId: integer): TList<TPayment>;
end;
implementation
[HttpGet]
function TMyService.Sum(A, B: double): double;
begin
Result := A + B;
end;
405 Method not allowed.
I wish the demos included the working source code of the tutorial.