简体   繁体   English

JMeter 测试包含 @ 作为路径参数的 url

[英]JMeter testing for the url which contains @ as path param

I have REST API which takes the username as a path parameter like this - app/users/{username}.我有 REST API,它将用户名作为这样的路径参数 - app/users/{username}。 As per the business requirement, the username can be an email address as well.根据业务需求,用户名也可以是 email 地址。 Application is developed and we can test using postman, curl etc., by encoding the URL.应用程序开发完成,我们可以使用 postman、curl 等进行测试,通过编码 URL。 But when we use JMeter to test the same API, We are not able to send the encoded URL using JMeter.但是当我们使用 JMeter 测试相同的 API 时,我们无法使用 Z406B391A8D2C4D45902A23A8B6585703DZ 发送使用 Z406B391A8D2C4D45902A23A8B6585703DZ 的 API。 To demonstrate the problem, I created a webhook site( https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter ) and requested as below.为了演示这个问题,我创建了一个 webhook 站点 ( https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter ) 并请求如下。

"GET https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter" “获取https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter”

This resulted in a webhook as below这导致了一个如下的 webhook

"https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter@jmeter" “https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter@jmeter”

But we want the output like below which we could accomplish by postman or curl.但是我们想要像下面这样的 output,我们可以通过 postman 或 curl 来完成。

curl --location --request GET 'https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter' curl --location --request GET 'https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter'

Please help how I need to prepare my JMeter script which produce the same output as above (in curl)请帮助我如何准备我的 JMeter 脚本,该脚本产生与上述相同的 output (卷曲)

I cannot reproduce your issue using latest JMeter 5.4我无法使用最新的JMeter 5.4重现您的问题

Not sure what does your "webhook" do, however in a sniffer tool like Wireshark request paths are exactly the same for curl and JMeter and no %40 doesn't get decoded into @不确定您的“webhook”是做什么的,但是在像Wireshark这样的嗅探器工具中,curl 和 JMeter 的请求路径完全相同,并且没有%40不会被解码为@

在此处输入图像描述

If you're capable of sending your request successfully via curl or postman you should be able to record it using HTTP(S) Test Script Recorder - this way you will get appropriate JMeter configuration.如果您能够通过 curl 或 postman 成功发送请求,您应该能够使用HTTP(S) 测试脚本记录器记录它 - 这样您将获得适当的 Z46B48EDA23B8864083D27FEB488C0F 配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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