Ask a Question

Need help in property transfer

rsubroto
New Contributor

Need help in property transfer

Hi, 

I don't know how to do a property transfer. I want to transfer the value of sid and token from the response. This is shown in the raw format. What to put in the source and target? Thank you!

Set-Cookie: sid=6b81b20c88254b60dcd83252200de2fe; path=/; secure; HttpOnly; SameSite=Lax
Set-Cookie: TOKEN=c1f8f1ae5d1be5f3860f31b066022bb9; path=/; secure; HttpOnly; SameSite=Lax

1 REPLY 1
KarelHusa
Champion Level 3

Hi @rsubroto ,

the Property Transfer does not support copying HTTP headers. 

 

You can insert a Groovy Script test step and use the following Groovy script to copy the value of an HTTP header into a TestCase property:

 

headerName = "theHeaderName"
headerValue = ""
testStepName = "theTestStepWithResponseName"

headers = context.testCase.getTestStepByName(testStepName).testRequest.response.responseHeaders[headerName]

if (headers != null && headers.size() > 0) {
headerValue = headers[0]
}

assert headerValue != "" : "The HTTP header missing in the response of " + testStepName
context.testCase.setPropertyValue(headerName, headerValue)

You need to set the variables:

  • headerName
  • testStepName

The assertion ensures that the Groovy Script test step fails if the response does not contain the expected HTTP header.

 

Best regards,

Karel

 

Karel@apimate.eu
https://apimate.eu
cancel
Showing results for 
Search instead for 
Did you mean: