boxes-api/scripts/searchitems.bash

23 lines
539 B
Bash
Raw Normal View History

#!/bin/bash
# API base URL
API_BASE_URL="http://localhost:8080"
# 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
curl -X GET \
http://localhost:8080/search/items?q=brand \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json'
# Print the response
echo "$response"