fork download
  1. #!/bin/bash
  2.  
  3. # API base URL
  4. API_URL="https://g...content-available-to-author-only...b.dev/api/v1/songs/id"
  5.  
  6. # Loop over the range of IDs from 20 to 5000
  7. for id in {20..5000}
  8. do
  9. # Perform DELETE request and capture the full response and status code
  10. response=$(curl -s -w "HTTP_CODE:%{http_code}" -X DELETE "$API_URL/$id")
  11.  
  12. # Extract the status code by splitting the response
  13. http_code=$(echo "$response" | sed -n 's/.*HTTP_CODE://p')
  14. body=$(echo "$response" | sed 's/HTTP_CODE:.*//')
  15.  
  16. # Check if the request was successful (HTTP status 200)
  17. if [ "$http_code" -eq 200 ]; then
  18. echo "Successfully deleted song with ID $id"
  19. else
  20. echo "Failed to delete song with ID $id, HTTP status code: $http_code"
  21. echo "Response body: $body"
  22. fi
  23. done
  24.  
Success #stdin #stdout 0.02s 25416KB
stdin
Standard input is empty
stdout
# API base URL
API_URL="https://g...content-available-to-author-only...b.dev/api/v1/songs/id"

# Loop over the range of IDs from 20 to 5000
for id in {20..5000}
do
  # Perform DELETE request and capture the full response and status code
  response=$(curl -s -w "HTTP_CODE:%{http_code}" -X DELETE "$API_URL/$id")

  # Extract the status code by splitting the response
  http_code=$(echo "$response" | sed -n 's/.*HTTP_CODE://p')
  body=$(echo "$response" | sed 's/HTTP_CODE:.*//')

  # Check if the request was successful (HTTP status 200)
  if [ "$http_code" -eq 200 ]; then
    echo "Successfully deleted song with ID $id"
  else
    echo "Failed to delete song with ID $id, HTTP status code: $http_code"
    echo "Response body: $body"
  fi
done