Advertisement
maskofa

Bridging BIOS - Data Capture :: Send Data

Nov 2nd, 2021
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.65 KB | None | 0 0
  1. function  TfrmUtama.sendData(AEndPoint, AJSONData: String): String;
  2. var
  3.   tok: String;
  4.   stm: TStringStream;
  5.   res: IHTTPResponse;
  6.   sss: String;
  7. begin
  8.   tok := getToken;
  9.   stm := TStringStream.Create(AJSONData);
  10.  
  11.   if tok = 'error' then
  12.   begin
  13.     result := tok;
  14.     exit;
  15.   end;
  16.  
  17.   http.CustomHeaders['Authorization'] := 'Bearer ' + tok;
  18.   http.CustomHeaders['Content-Type']  := 'application/json';
  19.  
  20.   try
  21.     res := http.Post(BURL_ + AEndPoint, stm);
  22.   except
  23.     on E:Exception do
  24.     begin
  25.       stm.Free;
  26.       result := 'error';
  27.       exit;
  28.     end;
  29.   end;
  30.   stm.Free;
  31.  
  32.   sss := res.ContentAsString;
  33.  
  34.   result := sss;
  35. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement