Jmeter错误 - “错误”:“unsupported_grant_type”,“error_description”:“不支持授予类型”

问题描述 投票:0回答:2

我正在尝试为Salesforce API测试设置Jmeter。但是,在Salesforce授权期间收到以下错误:

“error”:“unsupported_grant_type”,“error_description”:“不支持授予类型”

我正在传递参数截图中的参数。在Postman中传递的相同参数工作正常,但我在Jmeter中得到此错误。如果我在传递Jmeter中的参数时出错,请告诉我。

Jmeter_HTTP Header Manager

Jmeter_HTTP Request

Jmeter_Sampler Result

rest api jmeter salesforce
2个回答
0
投票

根据HTTP Status Code 400文件

超文本传输​​协议(HTTP)400错误请求响应状态代码指示服务器由于被认为是客户端错误(例如,格式错误的请求语法,无效请求消息成帧或欺骗性请求)而不能或不会处理该请求路由)。

看看你的请求,你发送Content-Type标题作为application/json因此你的服务器期望JSON,你提供的东西不同。

我的期望是你应该切换到Body Data采样器的HTTP Request选项卡,并将请求体设置为:

enter image description here

有关使用JMeter进行REST API测试的更多信息,请查看REST API Testing - How to Do it Right文章。


0
投票

我努力解决同样的问题,但最终通过以下方式为我工作:

  1. 在HTTP标头管理器中使用Content-Type application / x-www-form-urlencoded
  2. 确保是POST方法,并且您正在使用https
  3. 不确定是否有必要但是在参数选项卡中确保所有(grant_type,password,client_secret_ client_id和username)都是Content-Type application / x-www-form-urlencoded并检查所有的URL Encode选项
  4. 只检查HTTP请求中的“关注重定向”和“使用KeepAlive”选项

希望它也适合你

© www.soinside.com 2019 - 2024. All rights reserved.