nari447
nari447

Reputation: 934

How to set Request Header in Property transfer step in Soap UI using JsonPath

Im trying to set request header using property transfer step, but could not get anyway to access headers using JsonPath.

What to write in highlighted section to access request headers using jsonPath

enter image description here

Please help...

Response structure in Source:

   {  
      "payload": {
         "content": {
            "reason": "token successfully created",
            "success": "true",
            "authDetails": {
               "accessToken": "MyaccesToken",
               "expiresIn": "My ExpiryTime",
               "refreshToken": "MyRefreshToken"
            }
         }
       }
    }

Request structure in Target field

GET https://Myendpoint/myresouce/etc HTTP/1.1

Header1: myHeader1Value
Header2: **<Im trying to assign "MyaccessToken" in above step to this header>**

Upvotes: 0

Views: 4986

Answers (2)

geanakuch
geanakuch

Reputation: 972

I know I'm a bit late to the party but anyone who stumbles on this question now might still find this useful. You don't have to use the project's custom properties but you can define a property in the test case as well.

First append a Properties step to your test case: enter image description here

In that properties test step define a property called token (or any other name of your chosing).

Now add a Property Transfer step and choose Target: Properties (the step you just created) and Property: token (the property you just defined). enter image description here

Now you can access the contents of that property in all the test steps after that one by simply putting ${token}.

So probably you'll want to do something like in the headers section put

Authorization: Bearer ${token}

Upvotes: 0

Rao
Rao

Reputation: 21389

Here how you could achieve this:

  • Create custom property say TOKEN at project level.
  • In the property transfer step, use Target as Project name, and select TOKEN for Property.
  • For the request, click on header; provide name as required and value as ${#Project#TOKEN}
  • You can do the same for each request for which the same header is needed.

Upvotes: 5

Related Questions