-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBatchFile
More file actions
33 lines (31 loc) · 1.26 KB
/
TestBatchFile
File metadata and controls
33 lines (31 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
if [ "$#" -ne 2 ]; then
echo "Usage: <login_url> <rest_url>" >&2
exit 1
fi
echo "Clearing the previous rest response.."
rm rest_response.log
echo "Cleared !"
loginurl=$1
#username=\"$2\"
#password=\"$3\"
resturl=$2
echo "Login url : $loginurl"
#echo "Username : "$username""
#echo "Password : $password"
echo "Rest url : $resturl"
#loginjson="'{\"username\":$username, \"password\":$password}'"
#echo "Login json: $loginjson"
echo "Initiating login..."
# curl -X POST -i -H "Content-type: application/json" -c cookies.txt -X POST $loginurl -d '
# {
# "username":$username,
# "password":$password
# }
# ' >rest_response.log
#curl -X POST -i -H "Content-type: application/json" -c cookies.txt -X POST $loginurl -d $loginjson >rest_response.log
curl -X POST -i -H "Content-type: application/json" -c cookies.txt -X POST $loginurl -d '{"username":"1523439", "password":"rmwb123"}' >rest_response.log
wbtoken=`cat rest_response.log | grep wbToken | python -mjson.tool | grep wbToken | cut -d ":" -f2 | tr -d '"'`
echo "WB Token : $wbtoken"
echo "Logged in. Calling REST service $resturl now..."
curl -v -X POST -H "Content-Type: application/json" -H "WB-TOKEN:$wbtoken" -H "SYSTEM-ID:3" $resturl