Delphi HTTPApi and Enums

Hello,

Enums seem to be returned in thr HTTPApi as Unicode text. Is there a way to return Ansi?

Thanks,

Hi,

I can’t reproduce this case.

  NewEnum = (NewEnum_NewValue, NewEnum_NewValue1, NewEnum_NewValue2, NewEnum_NewValue3);
...
    [ROServiceMethod]
    [ROCustom('httpapipath', '/enum/echo/{NewParam}')]
    [ROCustom('httpapimethod', 'GET')]
    function NewMethod(const NewParam: NewEnum): NewEnum; virtual;
...
function TNewService.NewMethod(const NewParam: NewEnum): NewEnum;
begin
  Result := NewParam;
end;
C:\>curl -verbose -X GET "http://localhost:8099/api/enum/echo/NewValue1" -H  "accept: application/json"
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8099 (#0)
> GET /api/enum/echo/NewValue1 HTTP/1.1
> Host: localhost:8099
> User-Agent: curl/7.56.0
> Referer: rbose
> accept: application/json
>
< HTTP/1.1 200 OK
< Connection: close
< Content-Type: application/json; charset=utf-8
< Content-Length: 11
< Date: Fri, 08 May 2020 10:56:53 GMT
< Accept-Encoding: gzip, identity
<
"NewValue1"
* Closing connection 0

Can you create a simple testcase that reproduces this issue, pls?

Sorry this was an issue on our side where the value of the enum was cast outside the range of the enum. like

MyEnum(One,Two,Three)

Value := TMyEnum(99);