You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Oliver Lloyd <ol...@hotmail.com> on 2011/11/12 10:49:26 UTC

Re: How to obtain application/json GET responses

This sort of call is not an embedded resource so it will not be made
automatically when you select "Retrieve All Embedded Resources from HTML
Files", you need to make a separate direct call for it.

If you are getting a 403 response (and this call works fine in a browser)
then this suggests the server is not accepting the request because it is not
well formed. 403 is a vague response code but typically it is given because
you are missing a header, some part of the request is encoded / not encoded,
basic auth is not present or the request itself is not well formed. Try
comparing each part of the request that is sent in a browser (Firebug /
Chrome Dev tools etc.) with what you have in JMeter - there will likely be a
difference somewhere.

-----
http://www.http503.com/
--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-obtain-application-json-GET-responses-tp4985576p4986619.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: How to obtain application/json GET responses

Posted by Oliver Lloyd <ol...@hotmail.com>.
Cool, glad you got it working.

A couple of points:

1. I don't think you need the User Defined Variable. The Regular Expression
Extractor will automatically create a variable that you can reference in the
Header Manager. I'm guessing you can just take out the UDV control and
things will work the same.

2. You can change that regexp to:

Set-Cookie: XSRF-TOKEN=([^;]+);Path=/

The [^;]+ matches anything not like ';' and then repeats until ';Path=/' is
found. There's an assumption that ; is not present in the TOKEN value but
then this is very reasonable, in fact. it is essential.

This regexp is better because, one, it's more efficient (this is good
practice in general and actually really worth considering once you start to
ramp things up) and, two, it is more accurate - only selecting 0-9 or a-f
could very well be limiting, for ex., the regexp using [0-9a-f]+ will fail
(return 'NOT FOUND') if the XSRF-TOKEN contains any capitals, special chars,
or any letter from g-z, which is probable. 

-----
http://www.http503.com/
--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-obtain-application-json-GET-responses-tp4985576p4987561.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: How to obtain application/json GET responses

Posted by Oliver Lloyd <ol...@hotmail.com>.
If your app is using cookies to store the session and your test plan is not
sending the SESSIONID correctly in this ajax call then the chances are there
is a previous request that is wrong and this request is not setting the
cookie as expected (so it never gets sent back properly even if you do have
a HTTP Cookie Manager). You probably need to look further back in your test
plan to see why it is not getting the correct Set-Cookie response. This
could be for all sorts of reasons. 

Basically, you need to do a bit of digging using the View Results Tree
Listener and also in a browser to see where the Set-Cookie should be
received and why JMeter is not getting it. You might find that this earlier
request is getting an error in response but that the response code is still
200 so it appears as 'green' and gets passed by JM. In this case, try adding 
http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion
Response Assertion s to your requests.

To help you, try going through each of these:

http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager
HTTP Cookie Manager 
As far as I am aware, this control is (relatively) straight forward. Taking
it down to the basics, it will read Set-Cookie instructions (in the server
responses) and act upon them creating the required cookie in memory and
sending it with subsequent requests. There's more to it than that, but
that's the basics.

You need to make sure that it is in the correct scope. You can usually put
just one at a fairly high level in your test plan and that should do the
trick.

You can manually add cookies using this control.


http://jmeter.apache.org/usermanual/component_reference.html#View_Results_Tree
View Results Tree 
You probably already are but use this to see what is being sent and received
for each request,


http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Header_Manager
HTTP Header Manager 
Predictably, this sets headers. You probably have lots of them as a child to
each request (assuming you used the Proxy Recorder with default options).
The thing to remember here is again, scope, but also that multiple header
managers can be combined - if multiple controls are in scope then each
header value will be appended to the request.

You can manually specify extra headers here or edit recorded values.


http://jmeter.apache.org/usermanual/component_reference.html#HTTP_URL_Re-writing_Modifier
HTTP_URL_Re-writing_Modifier 
If your application is not using a cookie to store the session but instead
rewriting the URL then this control, using SESSIONID as the Session Argument
Name will help.


http://jmeter.apache.org/usermanual/best-practices.html#proxy_server
Recording via a Proxy 
Again, I'm assuming you are already doing this but, if not, then use this
method to record requests. It will record the request along with any
headers, url params, etc.


https://www.google.com/url?url=http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Authorization_Manager
HTTP Authorization Manager 
Allows you to set basic auth - if required. This probably isn't your
problem, if it were you'd likely get a 401, but who knows what weird code
you are working with - it's conceivable someone thought a 403 was a better
idea.


-----
http://www.http503.com/
--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-obtain-application-json-GET-responses-tp4985576p4987179.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org