Using your browser's Developer Tools window, use the UI to clear a queue while monitoring the network tab. Everything the Apache NiFi UI does is performed via the REST API. You will be able to see exactly what requests are sent to the server to clear the connection queue and can recreate that programmatically.
The specific API endpoint you want in this case is POST /flowfile-queues/{id}/drop-requests
where {id}
is the connection ID.