Are you 100% positive you’re connecting to a Jira SERVER instance, not Jira CLOUD. In Jira Cloud, the use of usernames and keys to identify users was deprecated ages ago. You must use the user’s accountId to identify them for all v2 and v3 REST API endpoints.
Can it be assumed the JSON in the body of the request uses plain double quote marks ("), not left and right quotation marks (“ and ”) as in your samples above?
A 500 error is an internal server error. It normally happens when you submit a mal-formed request with errant characters or bad structure.
Assuming that your Jira Server hasn’t recently been upgraded or changed, start by checking your code more thoroughly and comparing the current version with prior versions that were known to work. Try also testing that REST API endpoint with test tool like Postman to double check the fault.