0
votes

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?.

1

1 Answers

0
votes
  1. HTTP Status Code 500 stands for Internal Server Error, according to HTTP protocol specification the problem is on the server side as client status codes (i.e. malformed requests) should have HTTP Status code between 400 and 499. So I would recommend checking server-side logs, most probably you will be able to figure out what's wrong from them.
  2. It might be the case your ${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
  3. It might be the case your ${access_code} variable contains some special characters which are not allowed in JSON and must be escaped

    • Backspace is replaced with \b
    • Form feed is replaced with \f
    • Newline is replaced with \n
    • Carriage return is replaced with \r
    • Tab is replaced with \t
    • Double quote is replaced with \"
    • Backslash is replaced with \\

    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')),)}
    
  4. It might be the case you're not sending a proper Content-Type header so make sure to add HTTP Header Manager and configure it to send application/json as the Content-Type