Hello everyone, I have an api server (Delphi) and I am receiving requests from a client and when the credentials are invalid I return a json, but the json reaches the client as text plain.
Is there a way for it to arrive as json as it was generated?
example:
procedure TServices.RORemoteDataModuleGetDispatchInfo(
const aTransport: IROTransport; const aMessage: IROMessage);
var
HTTPInfo : IROHTTPTransport;
Authorization : string;
WWWAuthenticate : String;
Authorization_Decoded : String;
begin
try
if Supports(aTransport, IROHTTPTransport, HTTPInfo) then
begin
WWWAuthenticate := HTTPInfo.Headers['WWW-Authenticate'];
Authorization := HTTPInfo.Headers['Authorization'].Substring(Length('Basic')+
Pos('Basic ', HTTPInfo.Headers['Authorization']));
Authorization_Decoded := Soap.EncdDecd.DecodeString(Authorization);
if Authorization_Decoded <> (Api_User+':'+Api_Password) then
begin
raise EROHttpApiException.Create(HTTP_401_code, '{"State":"888","Message":"Descripcion"}');
end;
end;
finally
HTTPInfo := nil;
end;
end;