Reputation: 129
I been trying to write jmeter load test for a SAML secured web-service. So for i have a http request sampler which gets the access code and stores in a variable named access_code. But the web-service accepts post request in the form:
api.service.edu/api/authentication with body data as { "code":"${access_code}","redirect_uri":"some site"} .
but whenever I tried running the jmeter , my sampler gives the following error :
Thread Name: Basic App Usage Flow 1-1 Sample Start: 2018-11-07 21:08:50 EST Load time: 1209 Connect Time: 0 Latency: 1208 Size in bytes: 370 Sent bytes:0 Headers size in bytes: 324 Body size in bytes: 46 Sample Count: 1 Error Count: 1 Data type ("text"|"bin"|""): text Response code: 500 Response message: Internal Server Error
HTTPSampleResult fields: ContentType: application/json; charset=utf-8 DataEncoding: utf-8
is it because of the way I am parsing the access_code? if so how can I parse a dynamic value via a json post request?.
Upvotes: 0
Views: 862
Reputation: 168002
${access_code}
variable is not defined, i.e. the relevant Post-Processor failed to extract it from the previous response. Double check it's value using Debug Sampler and View Results Tree listener combination It might be the case your ${access_code}
variable contains some special characters which are not allowed in JSON and must be escaped
\b
\f
\n
\r
\"
\\
If your ${access_code}
variable contains any of the above - the resulting JSON will be incorrect. To be on the safe side I would recommend replacing your ${access_code}
variable reference with __groovy() function call
${__groovy(org.apache.commons.lang3.StringEscapeUtils.escapeJson(vars.get('access_code')),)}
application/json
as the Content-Type Upvotes: 0