It looks like the URI you are using resolves to a path that doesn't exist.
Based on JIRA Service Desk REST API Reference it looks like the URI for uploading an attachment to a ticket, looks a bit like this:
/rest/servicedeskapi/request/{issueIdOrKey}/attachment
It might be different based on environments, but this is as close as I could get it based on the provided information.
Suggest you try editing these two lines:
$jiraRestUrl = "http://xxxxxxx/jira/rest/api/2"
"$jiraRestUrl/issue/$jiraID/attachments"
To:
$jiraRestUrl = "http://xxxxxxx/rest/servicedeskapi/request/"
"$jiraRestUrl/$jiraID/attachment/"
Maybe you need to play around a bit with the API to figure out what works, maybe start by just retrieving a ticket based on the Jira Ticket ID?