# Http Api - multiline strings

**URL:** https://talk.remobjects.com/t/http-api-multiline-strings/31712
**Category:** Remoting SDK
**Tags:** delphi
**Created:** [May 19, 2025, 10:54am UTC](https://talk.remobjects.com/t/http-api-multiline-strings/31712 "2025-05-19T10:54:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Filip\_Lagrou](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/d6d6ee/32.png) [@Filip\_Lagrou](https://talk.remobjects.com/u/Filip_Lagrou)
#### Post date: [May 19, 2025, 10:54am UTC](https://talk.remobjects.com/t/http-api-multiline-strings/31712/1 "2025-05-19T10:54:31Z")

</div>

Hi

I have the following http method to post HL7 messages.

```auto
    [ROServiceMethod('HL7Message')]
    [RODocumentation('Adds a new HL7 message.')]
    [ROCustom(ApiRequestName, 'HL7Post')]
    [ROCustom(ApiPath, PATH + '/add')]
    [ROCustom(ApiResult, '201')]
    [ROCustom(ApiMethod, 'POST')]
    procedure HL7Message(const hl7: string);

```

A HL7 message looks like this

> **MSH** |^~&|MESA\_ADT|XYZ\_ADMITTING|iFW|ZYX\_HOSPITAL||| **ADT^A04** |103102|P| **2.4** ||||||||  
> **EVN** ||200007010800||||200007010800  
> **PID** |||583295^^^ADT1||DOE^JANE||19610615|M-||2106-3|123 MAIN STREET^^GREENSBORO^NC^27401-1020|GL|(919)379-1212|(919)271-3434~(919)277-3114||S||PATID12345001^2^M10|123456789|9-87654^NC  
> **NK1** |1|BATES^RONALD^L|SPO|||||20011105  
> **PV1** ||E||||||5101^NELL^FREDERICK^P^^DR|||||||||||V1295^^^ADT1|||||||||||||||||||||||||200007010800||||||||  
> **PV2** |||^ABDOMINAL PAIN  
> **OBX** |1|HD|SR Instance UID||1.123456.2.2000.31.2.1||||||F||||||  
> **AL1** |1||^PENICILLIN||PRODUCES HIVES~RASH  
> **AL1** |2||^CAT DANDER  
> **DG1** |001|I9|1550|MAL NEO LIVER, PRIMARY|19880501103005|F||  
> **PR1** |2234|M11|111^CODE151|COMMON PROCEDURES|198809081123  
> **ROL** |45^RECORDER^ROLE MASTER LIST|AD|CP|KATE^SMITH^ELLEN|199505011201  
> **GT1** |1122|1519|BILL^GATES^A  
> **IN1** |001|A357|1234|BCMD|||||132987  
> IN2|ID1551001|SSN12345678

Only the content is important, there are a few markdown-tweaks (asterisks) which are normally not there.

I’m not able to send such a message in the body of the request. How can I achieve this?  
I just want to send raw text data, no JSON or something else.

Pls advice.

Regards,  
Filip

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [May 19, 2025, 11:48am UTC](https://talk.remobjects.com/t/http-api-multiline-strings/31712/2 "2025-05-19T11:48:07Z")

</div>

Hi,

works here:

 ![Untitled](https://talk.remobjects.com/uploads/default/original/3X/8/2/8235f1d3ae270778a04ccb5c6c6d99a5add31d9e.png)

Note: I’ve used `curl` so in my case, hl7 value should be json compatible.

try:

> curl -v -X POST “[http://localhost:8099/api/add](http://localhost:8099/api/add)” -H “accept: application/json” -H “content-type: application/json” -d @a.json

- a.json

```auto
{
  "hl7": "MSH|^~\\\\&|MESA_ADT|XYZ_ADMITTING|iFW|ZYX_HOSPITAL|||ADT^A04|103102|P|2.4||||||||\r\nEVN||200007010800||||200007010800\r\nPID|||583295^^^ADT1||DOE^JANE||19610615|M-||2106-3|123 MAIN STREET^^GREENSBORO^NC^27401-1020|GL|(919)379-1212|(919)271-3434~(919)277-3114||S||PATID12345001^2^M10|123456789|9-87654^NC\r\nNK1|1|BATES^RONALD^L|SPO|||||20011105\r\nPV1||E||||||5101^NELL^FREDERICK^P^^DR|||||||||||V1295^^^ADT1|||||||||||||||||||||||||200007010800||||||||\r\nPV2|||^ABDOMINAL PAIN\r\nOBX|1|HD|SR Instance UID||1.123456.2.2000.31.2.1||||||F||||||\r\nAL1|1||^PENICILLIN||PRODUCES HIVES~RASH\r\nAL1|2||^CAT DANDER\r\nDG1|001|I9|1550|MAL NEO LIVER, PRIMARY|19880501103005|F||\r\nPR1|2234|M11|111^CODE151|COMMON PROCEDURES|198809081123\r\nROL|45^RECORDER^ROLE MASTER LIST|AD|CP|KATE^SMITH^ELLEN|199505011201\r\nGT1|1122|1519|BILL^GATES^A\r\nIN1|001|A357|1234|BCMD|||||132987\r\nIN2|ID1551001|SSN12345678"
}

```

* * *

I’ve received this json string with

```auto
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;

```

 ![](https://talk.remobjects.com/uploads/default/original/3X/1/8/189f7873728ad01412fe3288b9fcecd33c8ef0f8.png)

---

<div class="post-metadata">

### Author: ![Filip\_Lagrou](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/f/d6d6ee/32.png) [@Filip\_Lagrou](https://talk.remobjects.com/u/Filip_Lagrou)
#### Post date: [May 19, 2025, 1:07pm UTC](https://talk.remobjects.com/t/http-api-multiline-strings/31712/3 "2025-05-19T13:07:06Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [May 19, 2025, 2:04pm UTC](https://talk.remobjects.com/t/http-api-multiline-strings/31712/4 "2025-05-19T14:04:30Z")

</div>

Hi,

Json string is usual string, except that some chars should be quoted:

[![](https://www.json.org/img/string.png) ](https://www.json.org/img/string.png)

* * *

your original multiline string contains quoted chars so replace them as

- `\` → `\\`
- CRLF (#13#10) → `\r\n`
