formUpload with ssp template (or ElFileBody...)?

Hi,

For a formUpload() I’m currently using specific file content per user. With the increase of the number of (specific, authenticated) users this becomes undoable.

I’m looking at the filebody/spp functionality, but from what I read here it is depricated? (Also I couldn’t find if it is usable with formUpload(). I failed to figure out a way to use the apperent alternative, ElFileBody.

Could anybody give me a couple of pointers that could help me change the code below such that it uses a template file in the formUpload()?

`

`

def importXML(size: String, merge: Boolean) = exec(http(“Import merge” + merge.toString + “: /rapportage/DNB-M.2016-02.{userId}.e.xml?merge=” + merge.toString + " " + size)
.post("/ebridge/api/rapportage/DNB-M.2016-02.${userId}.e.xml?merge=" + merge.toString)
.headers(headers_import)
.formUpload(“file”, “rap-DNB-M-2016-2.${userId}.” + size + “.xml”)
).pause(Durations.lowPause, Durations.highPause)

`

`

Thanks,
Nol

formUpload is just an alias for bodyPart(RawFileBody), see http://gatling.io/docs/2.2.2/http/http_request.html#multipart-request

Thanks Stepan, that got me in the right direction.
That is to say, I can use a ‘template’ now, and values inside the tempate are replaced, but I get some errors. I think these are not related to the EL syntax, but apperently to the file content (in relation to the bodyPart/RawFileBodyPart I use). This file however is used before by the previous implementation (formUpload) without errors.

Is my combination of bodyPart - RawFileBodyPart - ElFileBody correct?

The new version of my code:

`

def importXML(size: String, merge: Boolean) = exec(http(“Import merge” + merge.toString + “: /rapportage/ABC-M.2016-02.{userId}.e.xml?merge=” + merge.toString + " " + size)
.post("/ebridge/api/rapportage/ABC-M.2016-02.${userId}.e.xml?merge=" + merge.toString)
.headers(headers_import)
.bodyPart(RawFileBodyPart(“file”, ElFileBody(“rap-ABC-M-2016-2.10k.xml”)))
//.formUpload(“file”, “rap-ABC-M-2016-2.${userId}.” + size + “.xml”)
).pause(Durations.lowPause, Durations.highPause)

`

The (first line) of my template (rap-ABC-M-2016-2.10k.xml):

`

<?xml version="1.0" encoding="ISO-8859-1"?><?bestandsnaam ABC-M.2016-02.**${userId}**.e.xml?><?eerstemaandrapportageperiode 2016-02?> etc. etc.

`

The error I got:

`

---- Errors --------------------------------------------------------------------

Failed to build request Import mergefalse: /rapportage/ABC-M.2 2 (Infinity%)
016-02.{userId}.e.xml?merge=false 10k: Failed to build request…