1

Here is my code :

var
  sTemp : string;
begin
  sTemp := IdHTTP1.Get('http://localhost:9001/datasnap/rest/TServerMethods1/ReverseString/123456789');
  ShowMessage(sTemp);

  // expected result : 987654321
  // the result i got : {"result":["987654321"]}
end;

I want the result to be : 987654321. Is this even possible? My goal is to result like this :

{"id":1,"pid":null,"PrjID":10001,"PrjName":"007项目","enable":false,"type":"SEO","manager":null,"members":null,"admin":null,"status":"INACTIVE","roleId":6,"manager2":0}

but it is resulting like this :

{"result":"{\"id\":1,\"pid\":null,\"PrjID\":10001,\"PrjName\":\"007项目\",\"enable\":false,\"type\":\"SEO\",\"manager\":null,\"members\":null,\"admin\":null,\"status\":\"INACTIVE\",\"roleId\":6,\"manager2\":0}"}

which is wrong. Where did I go wrong? I tried things like

IdHTTP1.Response.ContentType := 'application/json';

but still error. Thanks in advance.

Ago
  • 755
  • 7
  • 28
  • 1
    so we have to stick with SOAP for now, atleast we get things how we wanted. – Ago Mar 08 '18 at 05:47
  • 1
    Why would the programmers of DataSnap do such a thing? Why? Even if they have their own reasons, they should give application developers options. This makes me sad. – Ago Mar 08 '18 at 06:00
  • I am looking for ages to find a solution for this too. I need to return a HTML page and the server uses DataSnap. Now it returns something like "

    blalabla<\/p><\/html>" including the quotes.

    – Martien de Jong Jan 08 '20 at 09:16
  • @Remy Lebeau the page that you link to doesn't even explain why the content is escaped – Martien de Jong Jan 08 '20 at 09:24
  • @Ago does this page help? https://stackoverflow.com/a/23863734/1334119 I still have to try and implement this solution. It looks useful. – Martien de Jong Jan 08 '20 at 11:08
  • Does this answer your question? [Delphi DataSnap framework adding stuff to JSON message](https://stackoverflow.com/questions/4824063/delphi-datasnap-framework-adding-stuff-to-json-message) – Martien de Jong Jan 08 '20 at 11:09
  • I'm dealing with a similar issue, about TStream response. In Delphi XE3, a TStream response is processed as a content stream. After compiling the server with Delphi 10.4.1 the response is a JSON Array. I found out you have to include the "?json=false" parameter in the query in order to have a content stream: http://host:port/datasnap/rest/[Class]/[Method]/?json=true I tryed the "?json=false" with echostring method but result is always a json object. You can arrange the response as @Martien de Jong suggested – Giorgio Calzolato Nov 14 '20 at 22:13

0 Answers0