0

Delphi Rest send request with certificate? In the code I need to include the certificate files (cert.pem and cert.key). Thank you very much in advance.

  1. function teste(): WideString;
  2. var
  3. restClient: TRESTClient;
  4. restRequest: TRESTRequest;
  5. restResponse: TRESTResponse;
  6. begin
  7. restClient := TRESTClient.Create('');
  8. restRequest := TRESTRequest.Create(restClient);
  9. restResponse := TRESTResponse.Create(restClient);
  10. try
  11. try
  12. restclient.accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
  13. restclient.acceptcharset := 'utf-8, *;q=0.8';
  14. restclient.autocreateparams := true;
  15. restclient.allowcookies := true;
  16. restclient.baseurl := 'https://mtls-mp.hml.flagship.maas.link/auth/realms/matera/protocol/openid;
  17. restclient.contenttype := 'application/x-www-form-urlencoded';
  18. restclient.fallbackcharsetencoding := 'utf-8';
  19. restclient.handleredirects := true;
  20. restresponse.contenttype := 'text/xml';
  21. restrequest.accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
  22. restrequest.acceptcharset := 'utf-8, *;q=0.8';
  23. restrequest.acceptencoding := '';
  24. restrequest.client := restclient;
  25. restrequest.method := rmpost;
  26. restrequest.synchronizedevents := false;
  27. restrequest.response := restresponse;
  28. restrequest.params.add;
  29. restrequest.params.items[0].name := 'grant_type';
  30. restrequest.params.items[0].value := 'client_credentials';
  31. restrequest.params[0].kind := pkgetorpost;
  32. restrequest.params[0].contenttype := ctnone;
  33. restrequest.params.add;
  34. restrequest.params.items[1].name := 'client_id';
  35. restrequest.params.items[1].value := 'teste-hml';
  36. restrequest.params[1].kind := pkgetorpost;
  37. restrequest.params[1].contenttype := ctnone;
  38. restrequest.params.add;
  39. restrequest.params.items[2].name := 'client_secret';
  40. restrequest.params.items[2].value := '12345678';
  41. restrequest.params[2].kind := pkgetorpost;
  42. restrequest.params[2].contenttype := ctnone;
  43. restrequest.execute;
  44. result :=
  45. except
  46. on e: exception do
  47. begin
  48. result := restresponse.content;
  49. end
  50. end;
  51. finally
  52. restclient.free;
  53. end;
  54. end;

0 Answers0