JSON string result

Hi,

We have a service-method that returns a JSON-string

    [ROServiceMethod]
    [ROCustom('HttpApiMethod','GET')]
    [ROCustom('HttpApiPath','ApiService/GetOrder')] 
    function GetOrder([ROCustom('HttpApiHeaderParameter', '1')] const LamKey: string;
      [ROCustom('HttpApiQueryParameter', '1')] const Parameters: string): string;

The result we send looks like this (just a part of the string is shown)

[{"order_uid":154,"order_code":"F4D42X5WDUURQ2ZD","winkel_id":"A413","winkel_naam":"FRESHDIS /SPAR","status_code":"00","tijdstip_geplaatst":"2021-05-05T15:07:05","waarde":124.82,"waarde_leeggoed":4.5,"servicetype_code":"PICKUP","timeslot_start":"2021-05-07T09:00:00","timeslot_einde":"2021-05-07T09:30:00","opmerkingen_web_klant":"Voor de scampi''s: \"Het moog iet meer zin!\"","web_klant_id":"17","web_klant_naam":"Bert 2 Bastiaens","web_klant_telefoon":"+32499052841","web_klant_email":"[bert.bastiaens@gmail.com](mailto:bert.bastiaens@gmail.com)","web_klant_geboortedatum":"1980-01-10T00:00:00","lev_naam":"","lev_straat":"","lev_huisnr":"","lev_post_code":"","lev_gemeente":"","order_taal":[{"taal_code":"FRA","servicetype_omschr":"Récupération","status_omschr":"Importé"},

But what our customer receives is an escaped version of this string

[{\"order_uid\":154,\"order_code\":\"F4D42X5WDUURQ2ZD\",\"winkel_id\":\"A413\",\"winkel_naam\":\"FRESHDIS \/SPAR\",\"status_code\":\"00\",\"tijdstip_geplaatst\":\"2021-05-05T15:07:05\",\"waarde\":124.82,\"waarde_leeggoed\":4.5,\"servicetype_code\":\"PICKUP\",\"timeslot_start\":\"2021-05-07T09:00:00\",\"timeslot_einde\":\"2021-05-07T09:30:00\",\"opmerkingen_web_klant\":\"Voor de scampi's: [\\\"Het](file:///%22Het) moog iet meer zin!\\\"\",\"web_klant_id\":\"17\",\"web_klant_naam\":\"Bert 2 Bastiaens\",\"web_klant_telefoon\":\"+32499052841\",\"web_klant_email\":\"[bert.bastiaens@gmail.com\](mailto:bert.bastiaens@gmail.com\)",\"web_klant_geboortedatum\":\"1980-01-

Our customer has problems with this.
Is it possible to avoid escaping in the response .

Regards
Freddy

Hi,

try to change your method as

[ROServiceMethod]
[ROCustom('HttpApiMethod','GET')]
[ROCustom('HttpApiPath','ApiService/GetOrder')] 
function GetOrder([ROCustom('HttpApiHeaderParameter', '1')] const LamKey: string;
      [ROCustom('HttpApiQueryParameter', '1')] const Parameters: string): Binary;

you can put your JSON string to stream and return it as is:

function xxxx.GetOrder(const LamKey: string; const Parameters: string): Binary;
begin

   Result := TROHttpApiResult.Create(HTTP_200_code, 'text/plain','',true);
   Result.LoadFromUT8String(str);// or any other method that puts string to stream
end;

Read more about TROHttpApiResult at the HttpAPI in details article

Hi,

Thank you for the quick response !

~WRD000.jpg