These days have been called JMeter upload a file interface, has been wrong, find some articles on the Internet to note that attention has also been noted, or failure, finally found the reason.
1. When writing an API case, JMeter often uses the global header manager, the HTTP header manager. I set up a Content-type=application/jsonunder the thread group.
2. In the HTTP request under the Thread group, the intention was to add a new HTTP Header manager that could overwrite the global content-typeand then set it to Form-data, and later found that The relationship is not an overlay, but a relationship is added . Therefore, the null pointer error is always reported, because the file was found but not passed up.
3. In the Upload file HTTP request Sampler, add a BeanShell preprocessor, the global content-type remove, you can. Script:
Sampler.getheadermanager (). removeheadernamed ("Content-type");
4. If the next case wants to add back Content-type=application/json, BeanShell inside the code:
Import Org.apache.jmeter.protocol.http.control.Header;
Sampler.getheadermanager (). Add (New Header ("Content-type", "Application/json"));