REST API testing with gatling

Hello everyone,
I am trying to test REST API using gatling. But I am getting “, but actually found 400”. It’s for POST scenario. I have body parameters. So I configured “Headers and body”. please help me ASAP. I couldn’t figure out what went wrong in this.

package computerdatabase

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class BasicSimulation1 extends Simulation {

val httpConf = http.baseURL(“”)
.acceptHeader(“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”) // Here are the common headers
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36”)

val headers_10 = Map(“Content-Type” → “application/xml”)
// Note the headers specific to a given request

val scn = scenario(“My Scenario”) // A scenario is a chain of requests and pauses
.exec(http(“Top Speed”)
.body(StringBody("""{“highResVehicleUtilization”:{"-xmlns": “",“request”:{“vehicleDetails”:{"vin”: “RIGUD000000000057”,“chassisId”: “RIGUD-000057”},“driveSessions”:{ “driveSessionId”: “1460453954” },“duration”:{“fromDate”: “2016-05-27T10:30:10.000Z”,“toDate”: “2016-05-16T10:55:10.000Z”}}}}"""))


I’m new to Gatling, but the one thing I do differently is a payload. Try
.body(StringBody("{“highResVehicleUtilization”:{"-xmlns": “”,“request”:{“vehicleDetails”:{“vin”: “RIGUD000000000057”,“chassisId”: “RIGUD-000057”},“driveSessions”:{ “driveSessionId”: “1460453954” },“duration”:{“fromDate”: “2016-05-27T10:30:10.000Z”,“toDate”: “2016-05-16T10:55:10.000Z”}}}}")) or define payload variable and convert it to json before executing scenario (like described here).

Basically your API returns a 400 instead of the expected 200. Therefore you need to check if your request is really something that is expected on your API