1

This what my HTTP request is generating

Content-Type: multipart/form-data; boundary=V0a4bfuxfGhaH_Voo_Gu6oAEtj5FJNcp; charset=UTF-8

However, when compared to the POST data, it is lacking the 2 dashes in the front, which causes the server to reject the request:

--V0a4bfuxfGhaH_Voo_Gu6oAEtj5FJNcp
Content-Disposition: form-data; data="dataToBeSent"
--V0a4bfuxfGhaH_Voo_Gu6oAEtj5FJNcp--

How do I get Jmeter to generate the dashes in the header? (besides from manually creating the multipart form)

Note:

  • I am using the 'Use multipart/formdata for POST' option.
  • If I intercept the request and manually add the dashes in the header, the server accepts the request.
Michael Y
  • 143
  • 7
  • I wasn't able to get JMeter v. 3.3 to generate anything **different** from 2 dashes at the beginning. E.g. with java client: `Content-Type: multipart/form-data; boundary=---------------------------7d159c1302d0y0` with HttpClient4: `--U6pY3zGZBD_bx96zA7CvbGR8kqE_B5ppLF-- ` So older version? some other difference? – timbre timbre Dec 19 '17 at 23:36
  • @KirilS. I suppose it doesn't need to be exactly 2 dashes. As long as the boundary value in the header matches the value in the POST data. BTW, I was using v3.2. Ideally, it is prefered to have a solution in v3.2 – Michael Y Dec 20 '17 at 04:04

2 Answers2

1

You don't need to generate these values, the solution is to tick Use multipart/form-data for POST box in the HTTP Request sampler (or in the HTTP Request Defaults)

If you have any definition of Content-Type header in the HTTP Header Manager - you need to remove it and let JMeter generate appropriate Content-Type header on its own.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I am using the multipart form option already, the problem is that the generated value in the header does not have the dashes, while the value in the POST data does. – Michael Y Dec 21 '17 at 03:07
  • I got an issue with uploading data into Flask server. With Postman `multipart/form-data`, it's working fine. But not with the JMeter. As it mentioned in the answer, I removed the Content-Type header in the HTTP Header Manager, then it worked. But now I have to add `Content-Type` header into all other requests, rather having common HTTP Header Manager. @dmitri-t any suggestion on how to overcome this ? – gihanchanuka Mar 23 '19 at 21:59
1

The header doesn't need the dashes. This is simply how multipart/form-data works. The body is built as follows:

--<boundary>
<headers>

<content>
--<boundary>
<headers>

<content>
--<boundary>--

The -- part indicates a new part starts. The body ends with ---- to indicate no new parts will follow.

Rob Spoor
  • 6,186
  • 1
  • 19
  • 20