简体   繁体   中英

Jmeter Send wildcard % in JSON Payload of HTTP Request not returning correct response

I have a http POST request with JSON payload to search for devices owned by a customer with this body data:

{
  "@rpc": "1.0",
  "@data": [
    "dev%25",
    [
      "CompanyXYZ"
    ]
  ]
}

It should return a list of devices that begin with 'dev' like this:

device1
device2
device3

But instead is returning nothing. My header has:

  • Content-Type = application/json
  • X-CLIENTID = sdfsd8

How can I search for a set of data using a wildcard character like % in the body data of my HTTP Request? It seems like that is what I am seeing the endpoint do in our webapp.

I have tried these things with no luck:

  1. adding a charset=utf-8 to the header
  2. added content encoding=utf-8 to the HTTP Request and to the HTTP Request Defaults

I even tried the endpoint with just "dev%" and not "dev%25" but it is not encoding the % correctly and throws:

jmeter.protocol.http.visualizers.RequestViewHTTP: Error decoding query, maybe your request parameters should be encoded:

{
  "@rpc": "1.0",
  "@data": [
    "dev%",
    [
      "CompanyXYZ"
    ]
  ]
} java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "","
    at java.net.URLDecoder.decode(Unknown Source)

I don't see any problems using JMeter 3.1

JMeter 3.1 REST JSON POST

JSON request is set in Body Data tab of the HTTP Request sampler

HTTP Rest请求JMEter主体数据

See Testing SOAP/REST Web Services Using JMeter for comprehensive information on various aspects of API testing with JMeter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM