Jmeter 2.9 HTTP Sampler for PUT not passing parameters

 ̄綄美尐妖づ 提交于 2019-12-08 21:14:58

问题


I'm using Jmeter version 2.9, HTTP sampler to test my rest services.

The GET and POST are working without any issues, where as PUT is not passing any parameters in the request to the server.

I verified it with view results in tree.

Any reasons on why this is happening and work around this issue?


回答1:


It worked for me. Based on what I read on internet, there were different solutions suggested:

  • Changing Content-Encoding to UTF-8
  • Pass the PUT parameters in the "body data" tab (as opposed to passing them in tabular format in the "Parameters" tab)
  • Setting Content-Type header to application/json in the HTTP Header Manager
  • Passing the parameters via a file (even if this were to work, how would you pass dynamic values?)
  • passing it as POST with a combination of above points.

WHAT WORKED FOR ME is this combination: Set content type to application/json + Pass parameters as "JSON" in the **body data tab (below is an example)

I did not need to specify UTF-8 or anything else.

EXAMPLE JSON PARAMETER BODY: {"title":"JMeterTitle","preMortar":"JMeterPre","postMortar":"JMeterPost"}




回答2:


Pass parameters in path field using:

?name=value&name2=value2

and body in Raw Post body. if it doesn't work report a bug .

Example:




回答3:


First, try see the logs.

Had a similar problem. I was using wrongly the "Content-enconding" field as it were the HTTP Content-Type param. They are not related.

If you need to set Content-Type=application/json you have to use a "HTTP Header Manager" config element.

After setting correctly Content-enconding to UTF-8 the put request started to work.




回答4:


You should add a parameter with an empty name (in the "parameters" tab).

If the problem persists use the result tree view to analyze the request settings.




回答5:


I'm using JMeter 2.13 and facing with similar problem. This is How I've solved it:

  • Setting Content-Type header to text/plain in the HTTP Header Manager
  • Changing Content-Encoding to UTF-8
  • In the parameters tab, add the params without name and separated with ampersand character (&)

Screenshot JMeter PUT request example

Hope it helps!




回答6:


I am using JMeter 2.11 and I had the same problem. I solved in this way:

1) Setting Content-Type header similar to that you are using in your api method(Example: application/json or application/x-www-form-urlencoded etc.) in the HTTP Header Manager.

2)In HTTP Request. Body Data should look like this:

KEY=VALUE&KEY=VLAUE&KEY=VLAUE&KEY=VLAUE.......



来源:https://stackoverflow.com/questions/18163902/jmeter-2-9-http-sampler-for-put-not-passing-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!