Forum Discussion
richie
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 com.eviware.soapui.support.GroovyUtils( context ) groovyUtils.setPropertyValue("PROPERTIESTESTSTEPNAME", "HEADERNAME",value[0])
So the hierarchy I had in my test to get this to work was as follows:
TestCase 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!
richie
nmrao
6 years agoChampion Level 3
richie,
It was moved as the post says SoapUI 5.5.
I believe, the topic heading and description talks two different things.
nikki
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
https://stackoverflow.com/questions/42526729/get-the-token-and-send-it-as-value-for-authorization-header-for-the-rest-of-the/42540656#42540656
It was moved as the post says SoapUI 5.5.
I believe, the topic heading and description talks two different things.
nikki
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
https://stackoverflow.com/questions/42526729/get-the-token-and-send-it-as-value-for-authorization-header-for-the-rest-of-the/42540656#42540656
Related Content
- 5 years ago
- 2 years ago
Recent Discussions
- 11 days ago