I am sending an HTTP request and I want to pull the code=..... data in the "location" in the Response Header. However, I have not been successful.
The location section in the Response Header is as follows location: https://localhost/local?state=993bb8d7-323d-b5ee-db78-f976a59d8284&session_state=0b161be0-e2f2-4ba9-a5fd-a73f5fffc025&code=116de91f-d7ba-489e-b81b-9f51c82e1d9a.0b161be0-e2f2-4ba9-a5fd-a73f5fffc025.3d401675-7f2e-4258-b88d-986837f34d47
With Regular Expression Extractor, I get location data using "Location: .+/(.*?)\n". Then I try to get Code using the following code with Post-Processeur JSR223, but
ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, Post-Processeur JSR223 javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method split() on null object error.
String[] tab=vars.get("location").split("code=");
vars.put("code",tab[1]);
I tried a few methods but could not find a solution.
I think your regular expression extractor fails somewhere somehow so you location
variable is null.
If you get response header as location
(mind the lower-case l
) and try to extract it using Location
it will fail.
You need to amend your regular expression to ignore the case of the header name, something like:
(?i)Location: .+/(.*?)\n
First of all check that your location
variable has its anticipated value:
you can do this using Debug Sampler and View Results Tree listener combination.
and only then start looking for problems with your Groovy scripts.
More information: JMeter Regular Expressions