Error when deleting Computer Groups using a script (400 bad request)

New Contributor

I have a lot of unused computer groups that I would like to delete from our Jamf instance. I generated a list of their IDs and modified a script I used to delete devices to delete the groups en mass. However, I always receive a 400 Bad Request error when attempting to delete a computer group with an API request. I know that the URL is good because I get a response when sending a GET request. Here is the CURL request I am using: 

curl -fku $user:$password -H "Accept: text/xml" $server/JSSResource/computergroups/id/$i -X DELETE

I also tried using the group name instead of the id with the same result.