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.
- function teste(): WideString;
- var
- restClient: TRESTClient;
- restRequest: TRESTRequest;
- restResponse: TRESTResponse;
- begin
- restClient := TRESTClient.Create('');
- restRequest := TRESTRequest.Create(restClient);
- restResponse := TRESTResponse.Create(restClient);
- try
- try
- restclient.accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
- restclient.acceptcharset := 'utf-8, *;q=0.8';
- restclient.autocreateparams := true;
- restclient.allowcookies := true;
- restclient.baseurl := 'https://mtls-mp.hml.flagship.maas.link/auth/realms/matera/protocol/openid;
- restclient.contenttype := 'application/x-www-form-urlencoded';
- restclient.fallbackcharsetencoding := 'utf-8';
- restclient.handleredirects := true;
- restresponse.contenttype := 'text/xml';
- restrequest.accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
- restrequest.acceptcharset := 'utf-8, *;q=0.8';
- restrequest.acceptencoding := '';
- restrequest.client := restclient;
- restrequest.method := rmpost;
- restrequest.synchronizedevents := false;
- restrequest.response := restresponse;
- restrequest.params.add;
- restrequest.params.items[0].name := 'grant_type';
- restrequest.params.items[0].value := 'client_credentials';
- restrequest.params[0].kind := pkgetorpost;
- restrequest.params[0].contenttype := ctnone;
- restrequest.params.add;
- restrequest.params.items[1].name := 'client_id';
- restrequest.params.items[1].value := 'teste-hml';
- restrequest.params[1].kind := pkgetorpost;
- restrequest.params[1].contenttype := ctnone;
- restrequest.params.add;
- restrequest.params.items[2].name := 'client_secret';
- restrequest.params.items[2].value := '12345678';
- restrequest.params[2].kind := pkgetorpost;
- restrequest.params[2].contenttype := ctnone;
- restrequest.execute;
- result :=
- except
- on e: exception do
- begin
- result := restresponse.content;
- end
- end;
- finally
- restclient.free;
- end;
- end;