POST multipart/form-data cURL code generated from Postman is not imported correctly
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
**eR@SeR** ([Bug 65013](https://bz.apache.org/bugzilla//show_bug.cgi?id=65013&redirect=false)):
Hello,
When POST multipart/form-data request is opened in Code/cURL mode in Postman, then entire lines copied and pasted into "Import from cURL" in JMeter, generated HTTP Sampler is not completely correct:
1. Values in Parameters tab have redundant quotes
2. Values in File upload tab/File path have redundant quotes
3. MIME type value in File upload tab is application/octet-stream
If request with real URL and path is executed, the response is:
"java.io.FileNotFoundException: D:\jmxFileLocation"\D:\fileLocation\Desktop.jpg" (The filename, directory name, or volume label syntax is incorrect)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:116)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$ViewableFileBody.writeTo(HTTPHC4Impl.java:1513)
at org.apache.http.entity.mime.AbstractMultipartForm.doWriteTo(AbstractMultipartForm.java:134)
at org.apache.http.entity.mime.AbstractMultipartForm.writeTo(AbstractMultipartForm.java:157)
at org.apache.http.entity.mime.MultipartFormEntity.writeTo(MultipartFormEntity.java:113)
at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:156)
at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:152)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:238)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$2.doSendRequest(HTTPHC4Impl.java:458)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:935)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:646)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.base/java.lang.Thread.run(Thread.java:830)"
If the same request is executed when quotes from all values in parameters and file path in file upload tab are removed, and changing application/octet-stream to image/jpeg, response is then OK.
Maybe for some other APIs application/octet-stream might work, but for mine, it doesn't. Is it possible to check the extension and generate the MIME type according to it?
Check attachment for cURL example and screenshots.
Postman 7.36.1
Jmeter 5.4.1 54e820e
Microsoft Windows 10 Pro 64-bit
java version "1.8.0_251"
Created attachment [cURL and screenshots.zip](https://apache.github.io/jmeter-bugzilla-attachments/13/65013/37634/cURL%20and%20screenshots.zip): cURL and screenshots
Version: Nightly
Severity: normal
OS: All
Contributor guide
Assessment
This issue has not been assessed yet.