boxes-api/scripts/getitems.bash

22 lines
536 B
Bash
Raw Permalink Normal View History

#!/bin/bash
# API base URL
API_BASE_URL="http://localhost:8080/api/v1"
# Login credentials
USERNAME="boxuser"
PASSWORD="boxuser"
# 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')
# Request all items using the obtained token
response=$(curl -s -X GET -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"$API_BASE_URL/items")
# Print the response
echo "$response"