procedure TForm12.Button1Click(Sender: TObject);
var
x : TROJSONValue;
begin
x := TROJSONValue.Create(jdtString);
x.AsString := Memo1.Lines.Text;
memo2.Text := x.AsJSON;
x.Free;
end;
Strange thing…
I use Postman to test several situations. If I send the hl7 value as Text I don’t get the content of the string, sending as JSON has the correct content.
What I am trying to accomplish…
I really want the hl7 value as text. I did this before in the OnCustomResponseEvent like this:
procedure TdmServer.svrHTTPCustomResponseEvent(const aTransport: IROHTTPTransport;
const aRequestStream, aResponseStream: TStream; const aResponse: IROHTTPResponse; var aHandled: Boolean);
const
SErrorJSON = '{ "error" : {"class" : "%s", "message": "%s"} }';
SApplicationJSON = 'application/json; charset=utf-8';
var
aMsg: TStringStream;
aError: UTF8String;
Paths: TArray<string>;
begin
Paths := aTransport.PathInfo.Split(['/'], TStringSplitOptions.ExcludeEmpty);
aHandled := (Length(Paths) = 2) and SameText(Paths[0], 'hl7') and SameText(Paths[1], 'add');
if not aHandled then
Exit;
aMsg := TStringStream.Create('', TEncoding.UTF8);
try
aMsg.CopyFrom(aRequestStream, 0);
try
dmHL7.ProcessHL7(aMsg);
aResponse.Code := 200;
except
on E: Exception do
begin
// Send error back as JSON, UTF8 encoded
aResponse.Code := 500;
aResponse.ContentType := SApplicationJSON;
aError := UTF8Encode(Format(SErrorJSON, [E.ClassName, DoEscape(E.Message)]));
aResponseStream.WriteBuffer(aError[1], Length(aError));
end;
end;
finally
aMsg.Free;
end;
end;
So, if users need to change their processes they won’t be so happy
Is there a way to accomplish this?