You are not logged in.
Hi there everyone,
I have a mORMot REST server and I'm trying to send requests to it from a Java application.
Java strings are UTF16 by default and I want to get a list of users from the backend database by
sending query parameters in JSON format to the REST server.
I send a JSON string like this to the mORMot server:
{"etat":"Comptes activés"}
The mORMot server truncates the JSON string as follows:
{"etat":"Comptes
I made some changes and I noticed that the JSON string is not truncated when I send the
string with an underscore between the two words as follows:
{"etat":"Comptes_activés"}
The mORMot REST method looks like this
function TRESTMethods.Utilisateurs(Params: RawUTF8): RawJSON;
var
Res: ISQLDBRows;
Ctxt: TServiceRunningContext;
vParams: Variant;
begin
// Get the parameters - Java strings are UTF-16 by default so a convertion to
// UTF-8 is necessary here
vParams := _JsonFast(StringToUTF8(Params));
// NOTE vParams is empty when I send {"etat":"Comptes activés"} but it is OK
// when I send {"etat":"Comptes_activés"} with an underscore between 'Comptes'
// and 'activés'
// Set the current service context
Ctxt := CurrentServiceContext;
//
try
// more code here
finally
Res := nil;
end;
end;
Can anybody please help me resolve this problem.
Thanks a lot,
JD
Last edited by JD (2019-11-11 20:26:13)
Offline
You must encode url parameter (space = %20).
Esteban
Offline
Thanks a lot for the tip Esteban. It works properly now.
JD
Offline