Forum Discussion

nikki-zareen's avatar
6 years ago

How do i do a property transfer from a request header for an Access Token ?

I am using the SoapUI 5.5.0  and want to pass the bearer token from 1 api to the next . 

The bearer token is added in the post request of the header 

Everything blog i have read suggests to do a property transfer , however when i create a property transfer there is no option to select the request headers . It is the response of the api's which are available to select from . My api does not show the bearer token in any of the responses .

Can anyone tell me how i can pass on my token from the header to reuse for the next api ? 

Thankyou in advance 

2 Replies

  • richie's avatar
    Community Hero

    Hey nikki-zareen 


    @nmrao moved your ticket from the ReadyAPI! forum to the open source forum.


    Before now I've used the following groovy to write a header value to a Properties step


    //Takes one of the elements of the response Header
    def value = testRunner.testCase.testSteps["TESTSTEPNAME"].testRequest.response.responseHeaders["HEADERNAME"]
    //Read this value into a parameter
    def groovyUtils = new context )
    groovyUtils.setPropertyValue("PROPERTIESTESTSTEPNAME", "HEADERNAME",value[0])

    So the hierarchy I had in my test to get this to work was as follows:



        REST Request (teststep with relevant custom http header)
        Groovy Step (although you could probably add the above groovy to a groovy assertion instead
        Properties Step


    Hope I've understood and this helps!






    • nmrao's avatar
      Champion Level 3
      It was moved as the post says SoapUI 5.5.

      I believe, the topic heading and description talks two different things.

      The author of this thread wants to add token for his test steps to have the token send along with requests.

      Here is what it can be done:
      Save the token at project level custom property, say TOKEN, if you have it already in hand. (If you need to hit a request to get the token, then extract the same and then save it. You can achieve it using script assertion, and script may vary depending on the response or its headers that you receive)

      You can add header for Authorization for the requests and add value as ${#Project#TOKEN}. If you also need "Bearer " as prefix, add so.
      There is a catch here. It would be tedious if there are hundreds of existing tests.
      To overcome this, there are two ways,
      1 Write a program to add the header to each of the request and value as suggested above.
      2. Dynamically add header for each request that you submit. To do this, SoapUIPro has Event handling feature. For, Open Source, there is an extension available.
      You may find similar question here