Gatling Load Test - Error:“HTTP response: status= 406 Not Acceptable ”

345 views
Skip to first unread message

Arul Vendhan

unread,
Mar 22, 2017, 7:38:37 AM3/22/17
to Gatling User Group
I'm new to Gatling tool load test.

Working on a small project on sentiment analysis on movie reviews. I am passing JSON data to RestAPI hosted in my local machine. I wanted to perform load test using gatling tool, here is my code,

 
class BasicSimulation extends Simulation {
 val httpConf = http
 val scn = scenario("test")
     .exec(http("request_1")
     .body(StringBody("""{ "inputData": "Amazing movie" }""")).asJSON)
     .pause(7)
 setUp(scn.inject(atOnceUsers(30)).protocols(httpConf)}


In Gatling tool test, getting no errors in HTTP request , but getting error in HTTP Response as follows, "HTTP response: status= 406 Not Acceptable" and

ResponseProcessor - Request 'request_1' failed: status.find.in(200,304,201,202,203,204,205,206,207,208,209), but actually found 406.

Server end receives http request without any exception and tried printing inputData too, which works fine. But only in HTTP response I'm getting "HTTP/1.1 406 Not Acceptable "

Thanks in advance.

Barry Perez

unread,
Mar 22, 2017, 3:38:50 PM3/22/17
to Gatling User Group

You didn't add any headers to your request - you most likely need to add an Accept header with the appropriate content type.

As follows (using your code snippet):

class BasicSimulation extends Simulation {
 val httpConf = http
 val scn = scenario("test")
     .exec(http("request_1")
     .headers(myHeaders)
     .body(StringBody("""{ "inputData": "Amazing movie" }""")).asJSON)
     .pause(7)
 setUp(scn.inject(atOnceUsers(30)).protocols(httpConf)}

Where headers is a Map - example:

  val myHeaders = Map(
    "Content-Type" -> "application/json",
    "Accept" -> "application/json"
  )

Barry

Arul

unread,
Mar 23, 2017, 2:20:05 AM3/23/17
to Gatling User Group
Thanks for the response, 
I tried adding accept header with required content type. But still getting same error .     

Barry Perez

unread,
Mar 23, 2017, 4:04:33 AM3/23/17
to Gatling User Group

Can you get a request working in curl / postman? If so then simply evaluate the differences to work out what's missing or incorrect in your request.

Arul

unread,
Mar 23, 2017, 8:50:03 AM3/23/17
to Gatling User Group
Solved the Issue.
Found serialization error is the issue behind this in my code.
Thanks Anyway.  
Reply all
Reply to author
Forward
0 new messages