Forum Discussion

dev16's avatar
dev16
Contributor
8 years ago

how to use token id in second request

i am using soapui 5.2.1 where in first login request i am getting token id and this token id i want to use in second request so how to automated this token id and this token id will expire in 24 hrs . and my request and response is in JSON

 

Thanks,

Mahadev

  • AreN'T you supposed to get a json response? Just getting only token as response? A screen shot of raw response would help better. 

     

    If you just getting only token, then script needs to changed to handle that.

     

    If you have multiple users to test, then save them as : <USERNAME>_TOKEN at project level and use appropriately.

     

    for example, testuser token is fetched, save it as TESTUSER_TOKEN and its value at project level and use it as ${#Project#TESTUSER_TOKEN} where needed in the rest of the project.

     

    Hope this clear.

     

     

  • Re-iterating that you angular brackets needs to be removed.
    • dev16's avatar
      dev16
      Contributor

      Thanks for your valuable reply

      I am getting plain token id while Run the login request

      after login request, next step case is create one medical info .

       

       

      1) first login request----getting Token as response ( here i need to add script assertion as "def jsonString = context.response" ...correct ?)

      2) in second medical info add request ..in parameter what i need to add...or where and what i need to add 

       

      so please request you explain me elaborately because soapui rest api testing is new for me .. 

       

       this token id is expiring in 24 hrs so every time and every further step  i do not want to add token id so based on that plz guide me

      E.g. in response

      eyJdssdsddke90klfdO46j0dcJLx4t1XbE

       

      Thanks,

      Mahadev

      • nmrao's avatar
        nmrao
        Champion Level 3
        Can you please show the raw response of login step?

        Yes, once the token id is fetched store it at project level (unlike storing at test case level in the above thread)

        context.testCase.testSuite.project.setPropertyValut('TOKEN', <value>)

        Now, you for rest of your test steps / cases/ suites, you can use it as
        ${#Project#TOKEN}