Http Request With API Key Business Bentral

 


procedure GetRequest(AdditionalURL: Text; var Data: Text; var httpStatusCode: Integer): Boolean var NYAPISetup: Record "NYT API Setup"; httpClient: HttpClient; httpResponseMessage: HttpResponseMessage; requestUri: Text; begin NYAPISetup.get(); requestUri := NYAPISetup."Base URL" + AdditionalURL + 'api-key=' + NYAPISetup.GetAPIKey(); httpClient.Get(requestUri, httpResponseMessage); httpResponseMessage.Content().ReadAs(Data); httpStatusCode := httpResponseMessage.HttpStatusCode(); if not httpResponseMessage.IsSuccessStatusCode() then Error(RequestErr, httpStatusCode, Data); exit(true); end;

No comments:

Post a Comment