#!/bin/bash # API base URL API_BASE_URL="http://localhost:8080" # Replace with your actual API base URL # Box ID to delete items from BOX_ID=0 # Replace with the actual box ID # Login credentials USERNAME="boxuser" # Replace with your actual username PASSWORD="boxuser" # Replace with your actual password # Get a new JWT token TOKEN=$(curl -s -X POST -H "Content-Type: application/json" \ -d "{\"username\":\"$USERNAME\", \"password\":\"$PASSWORD\"}" \ "$API_BASE_URL/login" | jq -r '.token') # Get a list of all item IDs associated with the specified box ID ITEM_IDS=$(curl -s -X GET -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ "$API_BASE_URL/boxes/$BOX_ID/items" | jq -r '.[].ID') # Loop through each item ID and send a DELETE request for ITEM_ID in $ITEM_IDS; do curl -s -X DELETE -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ "$API_BASE_URL/items/$ITEM_ID" done