Home > Back-end >  How datasnap server receives HTTP post json data
How datasnap server receives HTTP post json data

Time:11-10

First HTTP post x - WWW - form - urlencoded data server can receive

Such as postman post http://192.168.1.208:38081/datasnap/rest/TServerMethods1/myMethord
Headers
The key value
The content-type application/x - WWW - form - urlencoded
Body x - WWW - form - urlencoded
The key value
First Value1
The Second Value2

Use GetInvocationMetadata server can obtain the data
The function TdmSFunc. UpdatemyMethord () : a Boolean;
Var
The metaData: TDSInvocationMetadata;
StrFirst strSecond: string;
The begin
Result:=False;
The metaData:=GetInvocationMetadata;
StrFirst:=metaData. QueryParams. Values [' First '];
StrSecond:=metaData. QueryParams. Values [' Second '];
Result:=True;
end;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- if the obtained data with application/json, don't know if -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Such as postman post http://192.168.1.208:38081/datasnap/rest/TServerMethods1/myMethord
Headers
The key value
The content-type application/json
The body raw JSON (application/JSON)
{" First ":" Value1 ", "Second", "Value2"},

Use GetInvocationMetadata server can obtain the data
The function TdmSFunc. UpdatemyMethord () : a Boolean;
The begin
Result:=False;
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- how to obtain the json data here -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Result:=True;
end;
  • Related