Hi,
would it be possible to programmatically change HTTP status code for a HttpApi method?
Even if it would be possible to change raising an Exception, I’d also need to return my object using a status code different from the default defined by code annotation.
my apologies for the delay; unfortunately part of our team if off today and tomorrow, for local holidays, so it might be until Wednesday to have an answer for this…
[ServiceMethod]
[ROCustom('HttpApiPath', 'test')]
function TestMethod(): Binary;
...
function TMyService.TestMethod(): Binary;
begin
Result := TROHttpApiResult.Create(HTTP_200_code, id_ContentType_image_jpeg,'',false);
Result.LoadFromFile(..image file location here..);
end;
you can put your json string to stream and return it …
another solution - use the OnCustomResponseEvent event as described at the OnCustomResponseEvent in a ROSDK Server topic.
here you can manipulate with request/response as you want …
The EROHttpApiException exception is written with text/plain; charset=utf-8 content type.
if you want to return error with other content type, you can use Using OnCustomResponseEvent in a ROSDK Server or return it via TROHttpApiResult.