mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9c2eebc4-dcd5-4b85-8113-90772d818900
23 lines
730 B
AL
23 lines
730 B
AL
codeunit 50210 "Sec Sample SecretHttp Bad"
|
|
{
|
|
procedure CallApiWithSecretInUri(ApiKey: Text)
|
|
var
|
|
HttpClient: HttpClient;
|
|
Response: HttpResponseMessage;
|
|
RequestUri: Text;
|
|
begin
|
|
RequestUri := StrSubstNo('https://api.example.com/data?key=%1', ApiKey);
|
|
HttpClient.Get(RequestUri, Response);
|
|
end;
|
|
|
|
procedure CallApiWithAccessToken(AccessToken: Text)
|
|
var
|
|
HttpClient: HttpClient;
|
|
Response: HttpResponseMessage;
|
|
Headers: HttpHeaders;
|
|
begin
|
|
Headers := HttpClient.DefaultRequestHeaders();
|
|
Headers.Add('Authorization', StrSubstNo('Token %1', AccessToken));
|
|
HttpClient.Get('https://api.example.com/data', Response);
|
|
end;
|
|
}
|