Running a Pascal Script on the start of a profile
Posted: Mon Mar 06, 2023 8:38 pm
I think I have this code correct, but It does not seem to be triggering or maybe it is, but I cannot tell, ultimately I am not getting the result I would expect on the other end of this request.
Obviously username, password, and url have been redacted
Please let me know if there is any obvious issues with this code
Code: Select all
function OnCanRunProfile(const ProfileName: UnicodeString; var PostponeBySeconds: Integer): Boolean;
var
ntfy_username, ntfy_password, PostData, AdditionalHeaders, URL, Response, ErrorResponse: AnsiString;
ResultCode: Int64;
begin
ntfy_username := 'username';
ntfy_password := 'password';
PostData := 'Backup of the Master Output share is starting';
AdditionalHeaders := 'Title: Syncovery Backup Starting...'+#10#13+
'Priority: default'+#10#13+
'Tags: arrows_counterclockwise'+#10#13+
'Authorization: Basic ' + EncodeBase64(ntfy_username + ':' + ntfy_password)+#10#13+
'Content-Type: application/x-www-form-urlencoded';
URL := 'https://ntfy.url.com/Beltzer';
ResultCode := 0;
Response := '';
ErrorResponse := '';
if SendHTTPRequest('POST', '', AdditionalHeaders, URL, PostData, ResultCode, Response, ErrorResponse) then
begin
// HTTP request was successful, do something with the response
end
else
begin
// HTTP request failed, do something with the error response
end;
Result := True; // or False, depending on your requirements
end;
Please let me know if there is any obvious issues with this code