使用Artillery.io执行负载测试时调用EntityRetrieve接口遇403错误
Artillery.io调用EntityRetrieve接口持续返回403,但Postman可正常请求
我在使用Artillery.io对特定用户执行负载测试时,调用EntityRetrieve接口持续返回403错误。但使用相同的userId、API地址、订阅密钥(Ocp-Apim-Subscription-Key)及授权密钥(AuthorizationSecured)在Postman中可成功获取用户信息,将相同配置写入Artillery的YAML脚本后,执行负载测试时控制台输出403状态码。
已尝试更换不同用户、API端点,问题仍未解决。另外,使用同一API地址、订阅密钥及授权密钥编写的Login接口负载测试脚本可正常运行,且EntityRetrieve接口无法像Login接口那样使用账号密码调用,必须使用userId。
报错的EntityRetrieve负载测试脚本
config: target: 'API endpoint link' timeout: 180 phases: - duration: 5 #arrivalCount: 1 arrivalRate: 1 maxArrivalRate: 1 defaults: headers: AuthorizationSecured: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlBhbXBlcnMiLCJleHAiOjE3MTUwNTUwOTcsImlhdCI6MTcwNzI5MzY1OX0.wT1QBik1la4Cnx5GQdBh_KBbwjJcURATMdnIgjqY1xA' Ocp-Apim-Subscription-Key: '2319f816b2c44bd8abf7598417bf9994' Content-Type: 'application/json' Cache-Control: 'no-store' processor: "my-functions.js" scenarios: - flow: - log: "PostUserAction - EntityRetrieve" - post: url: '/crm' beforeRequest: "logBodyReq" body: '{"locale": "hr-HR", "formType": "EntityRetrieve", "Params": { "userId" : "auth0|65d5a1fcbb247db30288d6c9" }, "getCustomData": false }' expect: - statusCode: 200 # - contentType: json afterResponse: "logResponse"
可正常运行的Login接口负载测试脚本
config: target: 'API endpoint' timeout: 180 payload: path: "Users.csv" fields: - "email" order: sequence skipEmptyLines: true phases: - duration: 4 arrivalCount: 2 # arrivalRate: 1 defaults: headers: Ocp-Apim-Subscription-Key: '77ede57299824292aa719d82b194c83a' Content-Type: 'application/json' Cache-Control: 'no-store' processor: "my-functions.js" scenarios: - flow: # start - log: "Login - Get Form" - post: url: '/Crm/GetForm' body: '{ "formId": "8e983cb7-6ffa-42e2-8c41-7d46432785a8", "formType": "Login", "locale": "en-US" }' afterResponse: "logResponse" - think: 3 # stop - log: "Login - User Action" - post: url: '/Crm' beforeRequest: "logBodyReq" body: '{"locale": "en-US", "formType": "Login", "Params": { "signInEmailAddress" : "{{email}}", "currentPassword" : "Testing123" } }' expect: - statusCode: 200 # - contentType: json afterResponse: "logResponse"
内容的提问来源于stack exchange,提问作者Jorge00
相关产品推荐
相关产品推荐

