newbie error

I’m a new user to Gatling. I have to load test a HTTP POST request which has XML Data. I’ve the following scala snippet

val headers = Map(“Content-Type” → “”“application/xml”"")
val scn = scenario(“Performance Test”)
.bodyPart(RawFileBodyPart(“binary”, “C:\tmp\test_file.xml”).contentType(“application/xml”).fileName(“test_file.xml”))


When i run this. I get a 400 error. Can please some one correct what it wrong with this.

Here is the corresponding cURL code I use which is executed successfully

curl -v -X POST --data-binary @C:\tmp\test_file.xml --insecure -H “Content-Type: application/xml” “https://myurl/new

more information from 400 error

When Gatlin posts this XML to the server, It adds these below 4 lines before the actual xml content

Content-Disposition: form-data; name=“data”; filename=“test_file.xml”
Content-Type: application/xml
Content-Transfer-Encoding: binary

So the server responds with 400 with below stack

Content is not allowed in prolog.

  • with linked exception:
    [org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.]

When cURL sends the same xml it doesn’t add those information so it works just fine. Can anybody provide me with an insight what i need to change.

Using BodyPart is for multipart.
You seem to only want a simple Body, not a BodyPart.

that worked thanks

New Issue this time around. I’m trying to make my request Dynamic.
I’m feeding a csv and the code is below

val headers = Map(“Content-Type” → “application/xml”)

val deal_info = csv(“test_info.csv”).random

def PostRequest = “”"

2014-10-25-2114-5033446-443045380 1 TEST TEST1 2015-01-09T10:14:39.265Z ${testID} 2014-01-09T11:20:49.266Z ${name} false ${quantity} ${price} """

val scn = scenario(“Performance Test”)
http(“Post Test”)
// .body(StringBody(PostRequest)).asXML


I tried both the RawFileBody and StringBody also tried to make them as xml.

When i run this, I get the below error. Looks like some problem with my body but i can’t figure it out

Exception in thread “main” java.nio.charset.MalformedInputException: Input lengt
h = 1
at java.nio.charset.CoderResult.throwException(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at Source)
at Source)
at Source)
at Source)
at Source)

The file editor you used for editing your file uses an encoding different from the one configured in gatling.conf (default is UTF-8).