Ad Widget

Collapse

Using Variables in Web scenarios

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bubbagump
    Junior Member
    • Sep 2021
    • 18

    #1

    Using Variables in Web scenarios

    I have a web scenario where I want to

    1. Send a POST and retrieve JSON with a token.
    2. Use that token in the next step in the header to then make a POST and get more JSON

    I am able to make the first POST though I don't know if I am creating the variable correctly.



    The resulting JSON looks like:

    Code:
    {
    "ageS": 1,
    "expiresInS": 2591999,
    "token": "SOMESUPERLONGTOKE123673528792475",
    "username": "admin"
    }

    Then I am trying to use the token in the header but I get a 401 so clearly it doesn't work.

    Click image for larger version

Name:	Screenshot 2024-11-06 at 12.12.24 PM.png
Views:	262
Size:	132.8 KB
ID:	493907

    An example in cURL of what does work

    Code:
    curl -k --header "Content-Type: application/json" \
    --request POST \
    --data '{"username":"admin","password":"somepassword","setCookie": true}' \
    https://10.10.10.214:7001/rest/v2/login/sessions
    Code:
    curl -s -k -H "Authorization: Bearer somelongtoken1278136487613784"\
    'https://10.10.10.214:7001/api/doCameraDiagnosticsStep?cameraId=fb680f2e-14cf-dc86-721f-f8d6958b4fa1&type=cameraAvailability'
    Any ideas?
    Last edited by Bubbagump; 06-11-2024, 20:08.
Working...