json – Delphi Web Service Parameters

Question:

I have a service running in Delphi with DataSnap REST, it serves to read data and returns the query to whoever requested it, but now the client needs to consume this data via the web passing some parameters, so good, I made the function it returns the data in a JSON array, my question would be how to handle the parameters it passes, such as

/?reference=BUTTON&type=raw_material&uid=BTN-1234

passing a reference= parameter in DataSnap REST would be like this

/datasnap/rest/TServerMethods1/function/parameter

there is no need to specify what you are going to search, with an equals sign just pass the parameters, does anyone have any ideas?

Answer:

I managed to solve the problem using the GetInvocationMetaData function, where it returns the parameters used in the link to the WebService . I'll put an example of how to use this function:

declare in usues Data.DBXPlatform

var  
  oMetaData: TDSInvocationMetadata  
  i: Integer;  
  s: String;  
begin  
  oMetaData: GetInvocationMetadata;

  for i := 0 to oMetaData.QueryParams.Count-1 do
  begin
    s := oMetaData.QueryParams[i];
  end;
Scroll to Top