procedure SendInvoiceWithAuthentication(EncryptedXMLBase64: Text; ClientID: Text; SecretKey: Text) ResponseText: Text
var
HttpClient: HttpClient;
HttpRequestMessage: HttpRequestMessage;
HttpResponseMessage: HttpResponseMessage;
RequestHeaders: HttpHeaders;
JsonToken: JsonToken;
JsonObject: JsonObject;
BodyText: Text;
BaseUrl: Text;
ResponseContent: Text;
JsonContent: Text;
ContentHeaders: HttpHeaders;
begin
BaseUrl := 'https://backend.jofotara.gov.jo/core/invoices/';
HttpRequestMessage.SetRequestUri(BaseUrl);
HttpRequestMessage.Method('Get');
HttpRequestMessage.GetHeaders(RequestHeaders);
RequestHeaders.Add('Client-Id', ClientID);
RequestHeaders.Add('Secret-Key', SecretKey);
JsonObject.Add('invoice', EncryptedXMLBase64);
JsonObject.WriteTo(BodyText);
JsonContent := BodyText;
HttpRequestMessage.Content().WriteFrom(JsonContent);
HttpRequestMessage.Content().GetHeaders(ContentHeaders);
ContentHeaders.Remove('Content-Type');
ContentHeaders.Add('Content-Type', 'application/json');
if HttpClient.Send(HttpRequestMessage, HttpResponseMessage) then begin
HttpResponseMessage.Content.ReadAs(ResponseContent);
if HttpResponseMessage.IsSuccessStatusCode then begin
Message('Success: %1', ResponseContent);
end else begin
Message('Error: %1', ResponseContent);
end;
end else begin
Message('Failed to send request.');
end;
end;