How to get header data from a RAW response into a parameter
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
12:17 AM
06-19-2012
12:17 AM
How to get header data from a RAW response into a parameter
I need to get a url in the header from a RAW response into a parameter.
How can I get the Location url into that parameter named e.g. location ?
The complete raw response (including body) looks like this:
----------------------
HTTP/1.1 201 Created
Server: some-server-idenifier
Location: https://some-server:some-port/some/url/unique-token
Date: Mon, 18 Jun 2012 07:11:11 GMT
Content-Type: application/some-content-type
Content-Length: 2
[]
----------------------
BR
/Wendigo
How can I get the Location url into that parameter named e.g. location ?
The complete raw response (including body) looks like this:
----------------------
HTTP/1.1 201 Created
Server: some-server-idenifier
Location: https://some-server:some-port/some/url/unique-token
Date: Mon, 18 Jun 2012 07:11:11 GMT
Content-Type: application/some-content-type
Content-Length: 2
[]
----------------------
BR
/Wendigo
10 REPLIES 10
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
12:36 AM
06-19-2012
12:36 AM
Hi,
what kind of requests are these two? (REST, SOAP, HTTP?)
regards,
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
what kind of requests are these two? (REST, SOAP, HTTP?)
regards,
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
12:47 AM
06-19-2012
12:47 AM
Hi
They are https calls.
I was thinking of having a DataGen (script) to get the url but can't figure out how to parse the response in a correct manner 😕
They are https calls.
I was thinking of having a DataGen (script) to get the url but can't figure out how to parse the response in a correct manner 😕
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
01:21 AM
06-19-2012
01:21 AM
Hi,
ok - are these HTTP TestSteps ? or REST ? (need to know so I can create the right script..)
thanks,
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
ok - are these HTTP TestSteps ? or REST ? (need to know so I can create the right script..)
thanks,
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
01:30 AM
06-19-2012
01:30 AM
HTTP test steps and I can retrieve the complete response (as described above) with:
def str = new String(testRunner.testCase.testSteps["init"].testRequest.response.rawResponseData)
return str
.. in a DataGen
def str = new String(testRunner.testCase.testSteps["init"].testRequest.response.rawResponseData)
return str
.. in a DataGen
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
04:02 AM
06-19-2012
04:02 AM
Hi,
you should be able to use
def str = testRunner.testCase.testSteps["init"].testRequest.response.responseHeaders["Location"]
...
does that work ok?
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
you should be able to use
def str = testRunner.testCase.testSteps["init"].testRequest.response.responseHeaders["Location"]
...
does that work ok?
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
04:22 AM
06-19-2012
04:22 AM
Almost
But I ger a[ at the start of the string and a ] at the end.
Like:
[https://some-server:some-port/some/url/unique-token]
But I ger a[ at the start of the string and a ] at the end.
Like:
[https://some-server:some-port/some/url/unique-token]
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
04:50 AM
06-19-2012
04:50 AM
Hi,
ok.. then just remove them with
str = str.substring( 1, str.length()-2)
?
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
ok.. then just remove them with
str = str.substring( 1, str.length()-2)
?
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
05:07 AM
06-19-2012
05:07 AM
Getting:
No signature of method: java.util.ArrayList.length() is applicable for argument types: () values: [] Possible solutions: last(), get(int), get(int), getAt(java.lang.String), getAt(java.util.Collection), each(groovy.lang.Closure)
No signature of method: java.util.ArrayList.length() is applicable for argument types: () values: [] Possible solutions: last(), get(int), get(int), getAt(java.lang.String), getAt(java.util.Collection), each(groovy.lang.Closure)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2012
05:40 AM
06-19-2012
05:40 AM
duh - I'm sorry - it should have been
def str = testRunner.testCase.testSteps["init"].testRequest.response.responseHeaders["Location"][0]
is that better?
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
def str = testRunner.testCase.testSteps["init"].testRequest.response.responseHeaders["Location"][0]
is that better?
/Ole
SmartBear Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
