I am trying to imply the basic authentication process for a web service using JMeter. But everytime it throws out an error 401:Unauthorized. I tried using the HTTP Header manager to add a header Authorization and value to it. Still it does not work. I have also tried using the HTTP Authorization manager. Still no luck. Can someone help.
解决方案
I've found through debugging requests coming in from JMeter that the HTTP Authorization Manager module doesn't encode the username and password correctly. It puts a newline character after the username.
To run a JMeter test against a Basic Auth protected endpoint, include the HTTP Header Manager and add the Basic Auth header yourself:
Manually Encoding Credentials
From MacOS or Linux:
echo -n "username:password" | base64
From Windows:
Go here and encode your "username:password" string
Adding the Authorization Header
In the HTTP Header Manager, add an entry with the name "Authorization" and the value "Basic [encoded credentials from above]"
博主尝试用JMeter实现Web服务基本认证,却总出现401未授权错误。使用HTTP Header manager和HTTP Authorization manager均无效。经调试发现,HTTP Authorization Manager模块对用户名和密码编码有误。解决方案是手动编码凭证,在HTTP Header Manager中添加授权头。
1844

被折叠的 条评论
为什么被折叠?



