Testing Tools

In different operating systems, you can install the tools wget and curl, and use wget or curl commands in the command line to call the API.

The locations where the cookie files are stored vary in different operating systems, and please modify according to the actual situation. (The following examples are based on Linux.)

wget

  1. Login and save cookies
wget --save-cookies=sid.txt --keep-session-cookies --header="Content-Type: application/json" --post-data='{"username":"Admin", "password": "c1c224b03cd9bc7b6a86d77f5dace40191766c485cd55dc48caf9ac873335d6f"}' http://192.168.66.1/api/user/login -d -q -O -
  1. Get the user list
wget --load-cookies=sid.txt --keep-session-cookies --header="Content-Type: application/json" --post-data='' http://192.168.66.1/api/user/get-all -d -q -O -
  1. Add a user
wget --load-cookies=sid.txt --keep-session-cookies --header="Content-Type: application/json" --post-data='{"username":"test","password":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"}' http://192.168.66.1/api/user/add -d -q -O -

curl

  1. Login and save cookies
curl --cookie-jar sid.txt http://192.168.66.1/api/user/login -X POST -H 'Content-Type: application/json' -d'{"username":"Admin", "password": "c1c224b03cd9bc7b6a86d77f5dace40191766c485cd55dc48caf9ac873335d6f"}'
  1. Get the user list
curl --cookie sid.txt http://192.168.66.1/api/user/get-all -X POST -H 'Content-Type: application/json' -d ''
  1. Add a user
curl --cookie sid.txt http://192.168.66.1/api/user/add -X POST -H 'Content-Type: application/json' -d '{"username":"test","password":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"}'

results matching ""

    No results matching ""

    results matching ""

      No results matching ""