JMeter upload file Form-data still fail solution

Source: Internet
Author: User
Tags http request json thread

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"));


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.